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
Web Development and Design Foundations with HTML5 (8th Edition)
Modern Database Management
Mechanics of Materials (10th Edition)
SURVEY OF OPERATING SYSTEMS
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (8th Edition)
- Write program in C++ Language The other solutions on chegg were incorrect! Please read carefully! Write a program that defines and tests a class called COP3014. The class resembles aclassroom. It has the following grading scheme:3 quizzes 20 points each 20%Mid term 100 points 30%Final 100 points 50%Based on the total grade of any student for the course, the letter grade of each student can becomputed as follows:Any grade of 90 or more is an A, any grade of 80 or more (but less than 90) is a B, any grade of70 or more (but less than 80) is a C, any grade of 60 or more (but less than 70) is a D, and anygrade below 60 is an F.This class needs to have some member variables. The first name, last name, the Z-number, thegrades, the total grade and final letter grade are all considered to be private member variablesof this class.The class should also have the following public member functions/procedural attributes that canbring the objects (students of the class) to life and give them some…arrow_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_forwardPlease help me with this C++ code. Please show work and code output. Write a class definition that stores information for a book. I want to store the following information about this book.arrow_forward
- Write a C++ code for this.arrow_forwardExercise 10 Automatic type conversion is called coercion. For example, if an int variable and a float variable are added in Java, the value of the int variable is coerced to float and a floating-point add is done. True or Falsearrow_forwardUse C++arrow_forward
- How do i solve this problem in python? ( has 3 steps)arrow_forwardIn C++arrow_forwardUsing C++ 11 Write a program which overloads fractions arithmetic operations for division. And include the overloading operators which we did in the class like multiplication, comparison, insertion, and extraction operators. Here is the class: class NumDays { int hr; //declaring hour variable to store hours float days; //declaring days variable to store days public: //default constructor NumDays() { hr = 0; days = 0.0; }; // parametrized constructor NumDays(int hrs) { hr = hrs; days = float(hrs / 8.0); }; // implementing getters method to return hours value from class int getHour() { return hr; } // implementing getters method to return no of days from class float getDays() { return days; } // method to implement addition operator NumDays operator + (NumDays obj) { int hrs = getHour() + obj.getHour(); NumDays temp(hrs); return temp; } // method to…arrow_forward
- a. Extend the definition of the class newString as follows:i. Overload the operators + and += to perform the string concatenation operations.ii. Add the function length to return the length of the string.b. Write the definition of the function to implement the operations defined in part a.c. Write a test program to test various operations on the newString objects.arrow_forwardDo not use regular expressions in your solution for this exercise. Write a program that checks to see if an input password is valid or not. In this exercise, a valid password has the following characteristics: It contains at least eight characters. It contains at most 12 characters. It contains only alphabetic characters, digits and the underscore (‘_’) character. It does not start with a digit. It has a mix of upper-case and lower-case characters. Your class must contain the following method: public static String checkPassword(String input) This method receives a possible password as input and returns only the String“OK” if the password is valid. If the password is not valid then you can return the reason(s) for that as the return value. This is not a part of the requirements, however, and you don’t need to do that. You can simply return null for an invalid password.arrow_forwardQuestion 2 Consider a Python class defined as follows. Note that there might be errors in the definition of this class. Which of the following statements is correct about the errors present in the class definition and how to correct them? Please note that there might be more than one correct statement, and you must choose all correct statements to receive full credit for this question. class Card: SUITS = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] definit(face, suit): self. face face if suit in SUITS: else: self.suit = suit raise ValueError The constructor expression of the class must have an input called "self" that refers to the created object. The conditional statement is incorrect and must be corrected as "if suit in Card.SUITS". The error that is raised in the class constructor is incomplete and misses a required text argument describing the nature of the error. The constructor expression of the class is named incorrectly and must be named as __init__. The conditional statement is…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT