The imperial system of measurements

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

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: EM13165681

Questions Cloud

Search for the value needle in the array : Search for the value needle in the array range given by [hay_begin ... hay_end), using the Linear Search algorithm. This function will return a pointer to the needle value if it is found, or a null pointer if needle is not found.
A java program where the user designates : a java program where the user designates how many games they would like to play (for example user inputs 10 games) then they play the game, if lets say there is a tie after 10 games the game continues until either the user of the computer wins by 2
What happens when you assign : What happens when you assign 340,282,343,598.33 to a Single variable? Assuming that the variable in question is named sngNumber and you execute the statement MessageBox.Show
Supposed to swap numbers : The program is supposed to swap numbers, but I am stuck something is wrong! It does not swap them it repeats the second number, please help to fix! Thanks, this is in C++.
The imperial system of measurements : 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.
What do the loops print : What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. int s = 1; for (int n = 1; n
The ieee 754 single precision binary representation : What would be the IEEE 754 single precision binary representation of the floating point value -314159265. 3589 ? Express your final answer as an 8-hex-digit number and explain how your answer was obtained for full credit.
Child process to take the role of the number guesser : Write a program in C that takes a number between 1 and 1024 as input on the command line, and then forks a child process to take the role of the number guesser
Assume that a student table in a university : Assume that a student table in a university database has an index on StudentID (the primary key). and additional indexes on Major, Age, Marital status, and HomeZipCode.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Once the user enters a 0

Once the user enters a 0 you will exit the loop, close the file and execute the code as previously designed until you have displayed all of the scores and the average handicap.

  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

  Write a pseudocode statement

Assume that a program has two string variables named str1 and str2. Write a pseudocode statement that assigns an all uppercase version of str1 to the str2 variable. is str.add(str1,str2) part of it?

  Braces for blocks of code

C-- should have braces for blocks of code, an if statement, while statement, and a double, int, and character. Each statement ends with a semi-colon and you must have a main routine

  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.

  Person class that includes fields for last name

Create a Person class that includes fields for last name, first name, and zip code. Include a default constructor that initializes last name, first name, and zip code to "X" if no arguments are supplied. Also include a display function. Write a ma..

  The funtion should take as parameters

Write a function in c ++ that multiplies two functions. the funtion should take as parameters two fraction structures. Then, the function should multiply the two fractions and return the solution as a fraction structure.

  Write short c program to develops two processes

Write down a short C program which develops two processes. Each process must repeatedly write its own unique message to test file, one character at time. Do you see garbled messages in the file? Explain why or why not?

  Object-oriented systems is the concept of object

At the heart of all object-oriented systems is the concept of an object. Simply stated, an object is a set of related characteristics and their associated actions.

  Program to compute and show miles per gallon

Create the program in C++ which will input miles driven and gallons used (both as integers) for each tankful. Program must compute and show miles per gallon.

  Draws a single level for a "rogue­like" computer game

You will write a program that draws a single level for a "Rogue­like" computer game. The program will parse a line of input text from an input file (room.txt), use the parsed text to determine the shape of the room and its contents and then draw the ..

  Design a phonecall class that holds a phone number

Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute. Overload extraction and insertion operators for the class.

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