Concept explainers
Define a class for rational numbers. A rational number is a number that can be represented as the quotient of two integers. For example, 1/2, 3/4, 64/2, and so forth are all rational numbers. (
By 1/2 and so on we mean the everyday fraction, not the integer division this expression would produce in a
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Absolute C++
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting out with Visual C# (4th Edition)
Problem Solving with C++ (10th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with C++: Early Objects
- Code in C++ Language As a cashier, you would always hate those times when customers choose to take back their order since you'd always summon your manager and yell, "Ma'am pa-void!" No matter how you hate it, you always have to do it since you have no other choice. Given (1) an array of prices of the items, (2) another array of the items the customer wishes to take back, and (3) the customer's payment, print the change of the customer. Input: The first number indicates the number of items "n" brought to the cashier. The next "n" numbers are the prices of the items. The next number indicates the number of items "m" that the customer wants to take back and not proceed. It is assured that 0 <= m <= n. The next "m" numbers are the items to be void that ranges from item 1 to item "n". The final number is the customer's payment. It is also assured that the given payment >= final price of items. INPUT: 5 103.65 650.95 10.25 1067.30 65.18 2 1 5 2000.00 Output: The change…arrow_forwardC++ Write a program that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, say, romanType. An object of type romanType should do the following: Store the number as a Roman numeral. Convert and store the number as a positive integer. Print the number as a Roman numeral or positive integer as requested by the user. The integer values of the Roman numerals are: M 1000D 500C 100L 50X 10V 5I 1 Test your program using the following Roman numerals: MCXIV, CCCLIX, and MDCLXVI.arrow_forwardWrite C++ code of class Complex that would represent a complex number. A complex number consists of a real part and an imaginary part and usually displayed in the form + ἰ (a is real part while b is imaginary). This class should consists of void show( ) to display the complex number in the form a+ bi ( if imaginary part is positive) or a – bi ( if imaginary part is negative), void input( ) to assign values to the object of the Complex class. This Complex class should have two constructors i.e. default and parameterized. The object instantiated using default constructor should call input() to assign value to the real and imaginary part of the object. Also write code to overload + operator to add two complex numbers (objects). Comment your program properly and mention mutator and accessor as well. All functions should be inline except the constructors. Use this pointer wherever class data members are referred.arrow_forward
- in C++ Language can you answer that questionarrow_forward1arrow_forwardDefine a new C++ class named “PayStub” that manages pay information: numberof hours (integer), hourly pay rate (double).The total payout amount will be calculated based on overtime. Any hour that ismore than 40 hours will be paid at a 1.5 pay rate.For example, with the hourly pay rate of $10.0 and if the number of hours is 40,the payout amount will be 400 and if the number of hours is 50 it will be (40 * 10)+ (10 * 15) = 550Please note that because the payout is a calculated value, it should not be part ofthe data members to make the object as small as possible.The class must provide at least the following two methods: • toString method that returns the string containing all the information aboutthe paystub including the total payout amount.For example, here is the output for different paystubs40 hours at $10.0 an hourHOURS(40) RATE($10.00) PAYOUT($400.00)50 hours at $10.0 an hourHOURS(50) RATE($10.00) PAYOUT($550.00)60 hours at $10.126 an hourHOURS(60) RATE($10.13)…arrow_forward
- Java: Design the class Circle that can store the radius and the center of the circle based on the class Point we talked in the class. You should be able to perform the usual operation on a circle, such as setting radius, printing the radius, calculating and printing the area and circumference, and carrying out the usual operations on the center. Here is the code: public class Point {public static void main(String[] args) { } protected double x, y; // coordinates of the Point //Default constructorpublic Point(){setPoint( 0, 0 );} //Constructor with parameterspublic Point(double xValue, double yValue ){setPoint(xValue, yValue );} // set x and y coordinates of Pointpublic void setPoint(double xValue, double yValue ){x = xValue;y = yValue;} // get x coordinatepublic double getX(){return x;} // get y coordinatepublic double getY(){return y;} // convert point into String representationpublic String toString(){return "[" + String.format("%.2f", x)+ ", " + String.format("%.2f", y) + "]";}…arrow_forward3. Write Java program that will calculate the amount to be paid for electrical consurmption This problem is to handle electric billing for customers. The billing is depending on the type of the customer account There are two types of customer account, 1) fixed rate method and 2) variable rate method In the case of fixed rate method, the minimum monthly charge of RM20 00 is assessed if the consumption is less than or equal 100 KWh (kilowatt hours). Otherwise the rate of RMO 22 per kWh is charged for the first 100 KWh and the rate of RMO 33 per kWh is charged for the additional consumption. In the case of variable rate method, the rate of RMO.22 per kWh is charged for the consumption less than or equal to 100 kWh. Any additional consumption is charged at RM0.35 per kWharrow_forwardC++arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT