Integer arguments representing feet

Assignment Help C/C++ Programming
Reference no: EM13165394

The Imperial system of measurements uses feet and inches for length, where 1 foot is equal to 12 inches. Write
a class named Imperial that will represent distance measurements in feet and inches. Your class should
include the following:
Attributes:
• A single private integer value that will maintain the measurement in units of 1/16 of an inch

Constructors:

  • The default constructor should initialize the value to zero

• A constructor that will take a single integer argument representing a whole number of feet
• A constructor that will take two integer arguments representing feet and inches respectively
• A constructor that will take three integer arguments representing feet, inches and inch-fractions

 

Methods:
• fp: will take no arguments and return the number of inches as a double-precision floating-point
value
• cm: will take no arguments and return the value of the Imperial measurement in centimeters as a
double precision floating-point value
• getValue: void method that will take three reference arguments and return the feet, inches and
fractions of inches

Operators:
• Overload the << operator as a non-member friend of the class. The operator should work with any
stream and display the Imperial measurement as feet, inches and fractions of an inch as follows (all
punctuation and spaces as shown):
2' 3 5/16"
Display any non-zero fractional inch values in reduced form. i.e., 4/16 would be displayed as 1/4.
Do not display zero fractional-inch values. Do not display zero feet values.

Write a main program to test the correct operation of your class. Include the following code (at a minimum):

Imperial m1;
Imperial m2(43);
Imperial m3(0,4);
Imperial m4(1,3,6);
Imperial m5(0,0,12);
Imperial m6(4,0,5);
Imperial m7(0,3,2);
Imperial m8(12,3,0);
cout << m1 << endl;
cout << m2 << endl;
cout << m3 << endl;
cout << m4 << endl;
cout << m5 << endl;
cout << m6 << endl;
cout << m7 << endl;
cout << m8 << endl;
int feet, inches, fractions;
m4.getValue(feet,inches,fractions);
cout << feet << ',' << inches << ',' << fractions << endl;
cout << m5.fp() << endl;
cout << m4.cm() << endl;

Example output:
0"
43' 0"
4"
1' 3 3/8"
3/4"
4' 5/16"
3 1/8"
12' 3"
1,3,6
0.75
39.0525

Reference no: EM13165394

Questions Cloud

Which graduated cylinder would have the greatest volume : The density of aluminum is 2.70 g/cm3 and the density of chromium, is 7.19 g/cm3. If equal masses of aluminum and chromium are transferred to equal volumes of water in separate graduated cylinders, which graduated cylinder would have the greatest ..
Access time for reading a word from a virtual address : Consider a computer system where the overhead required for reading a word from the page table is 1.25ms. A TLB lookup of a word requires 250 ns.
What is the minimum mass of sulfur dioxide necessary : What is the minimum mass of sulfur dioxide necessary to produce 200. grams of sulfuric acid in the reaction?
Evaluate and use quantitative and qualitative information : Evaluate and use quantitative and qualitative information to measure financial and non financial performance of an organisation
Integer arguments representing feet : A constructor that will take a single integer argument representing a whole number of feet • A constructor that will take two integer arguments representing feet and inches respectively • A constructor that will take three integer arguments represent..
Program to generate a star-based histogram for a quiz : Write a C++ program to generate a star-based histogram for a quiz (maximum score possible is 5) given to a class of N students, where N is an input from the user. Use arrays for computation.
State newton''s third law of motion : Newton's third law of motion can be stated like this: "For every action, there is an equal and opposite reaction." How are Le Chatelier's Principle and Newton's third law similar? How are they different?
Program that can serve as a simple calculator : Write a program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0. Each cycle allows the user to repeatedly add, subtract, multiply, or divide by..
Determine the center temperature of the product : Determine the center temperature of the product afer 60 minutes if the convective heat transfer coefficient between the product and mbient air is 25 W/m^2 K.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a c function void print_triangle(int n)

Write a C function void print_triangle(int n) that prints a triangular pattern of asterisks of height n and width 2 * n + 1 with one asterisk in the first line, three in the second line, etc.,

  Develop a program that when you pipe in a file

develop a program that when you pipe in a file it will demonstrate on the left had side the line number  work by having a program piped in and when a \n occurs a new line and number is indicated.

  Create a template class

Create a template class, SVector, that implements a constructor

  Program to compute the total volume

Write a program to compute the total volume for a number of cylinders. A cylinder may have different values for height and radius.

  Write main function to compute stress-strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads.

  Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  Write the output of the program

Design a C++ program that will interactively prompt for and read the name of the input file interactively prompt for and read the name of a file to write the output of the program to write the following to the specified output file your name, sect..

  Write a program that inputs a dollar amount to be printed

Write a program that inputs a dollar amount to be printed on a check and then prints the amount in check-protected format with leading asterisks if necessary

  By a minimal interpretation that makes a formula

By a minimal interpretation that makes a formula true, we mean that if one atom is removed from the interpretation then the resulting interpretation does no longer make the formula true.

  Create a file, shared.txt

When your program starts, it shall do the following:1. Create a file, SHARED.txt, in the current directory (cwd). 2. Write it's pid (Process ID) followed by a Carriage Return and Newline in the file.

  Write a program that takes a positive integer

Write a program that takes a positive integer from the user and prints the rightmost digit of that integer. This is a sample output: Enter an integer: 1247

  Program to compute surface area of sphere using function

Write down a program in C++ to compute surface area of sphere using a function. As sample run, write down the surface areas of spheres with radii.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd