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

  Data from the file grocery.dat

Read the data from the file Grocery.dat and assign values to the 10  GroceryItem  objects. Next display these items to allow a customer to select grocery items from the list and indicate the quantity of that item he or she would like to order. When t..

  Program that displays the ball at a random

Write a C++ program that displays the ball at a random location and then makes the ball move down to the bottom of the screen. When the ball reaches the bottom of the screen, it should start these actions over again, appear-ing at another random l..

  Public transport fare ticketing system

Implement and test a public transport fare ticketing system.

  Implement a function to recursively

Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.

  Assessment system of a university

Write a program for Assessment system of a University

  Grocery store program

This program draws upon several concepts that were covered in CptS 121 and should serve as a good refresher for CptS 122. Our store, Cougar Mart, maintains its inventory in a text file. Not being very tech savvy, the owner of Cougar Mart needs you to..

  Three or more dimensions

What kind of program, or problem, might necessitate arrays of three or more dimensions?

  The mean and standard deviation

How do i write a program in c++ that use functions max, min, the total numbers, the mean and standard deviation to read a file text and return these values from the file text. note the file text has random numbers. note im not suppose to use arrays.

  Difference between a constant pointer

Explain the difference between a constant pointer to non-constant data and a non-constant pointer to constant data. Show the syntax to declare them.

  C program that compare the time required

Write a C program that compare the time required to compute the product of two 10,000 x 10,000 matrices with and without optimization for locality.

  Design a class named employeerecord

Design a class named EmployeeRecord that holds an employee's ID number, name, and payrate. Include mutator methods to set the values for each data field and output the values for each data field. Create the class diagram and write the code that

  Program to compute diameter in centimeters of a steel rod

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

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