Questions: 11 448

Answers by our Experts: 10 707

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

You are required to build a class to represent the a cup of coffee. Call your class 

CoffeeCup. A coffee cup will have following characteristics 

1. type (sting) // can be mocha, cupaccino, etc 

2. temperature (float): 

3. volume (float):

4. sugar (int): 

Provide these methods 

1. parameterized constructor CoffeeCup(string t, float temp float vol, int sug) 

2. Provide setters for temperature, and sugar and volume. 

3. Provide getters of temperature, sugar, volume and type. 

4. void heatUp():

5. void cooldown(): the process of cooling down. The temperature goes down by one degree but 

will not go below 0 

6. bool isSweet():

7. bool hasMore(): 

8. bool isEmpty(): 

9. bool takeASip(): 

10. Provide a method print, that displays the status of the cup with respect to all data members.


In C++ Make a class CoffeeCup. A coffee cup will have following characters: type (string): mocha, cupaccino, etc. Temperature (float): represents the measure of temperature in degrees. Volume (float):volume of coffee in the cup in ml. Sugar (int): no. of teaspoons of sugar added to coffee. Provide parameterized constructor CoffeeCup(string t, float temp float vol, int sug). Provide setters & getters of temperature, sugar, volume and type. bool hasMore(): this method checks if the cup has coffee in it that a person can take a sip from. Assume that one sip consumes a volume of 0.3 ml. So do some calculations in this method to check if it has any sips left depending upon the volume available. bool isEmpty(): returns true if a person can take a sip from this cup and false otherwise. bool takeASip(): this method represents the actual act of sipping. One sip is taken i.e. the volume equivalent to one sip is taken away. Provide a method print, that displays the status of the cup with respect to all data members


The volume, v, and side surface area, s, of a cylinder are given by the formulas v= _r 2l s = 2_rl where r is the cylinder’s radius, and l is its length. Using these formulas, write a c++ program with a function named cylinder()that accepts a cylinder’s radius and length and returns its volume and side surface area. Only in main() function will display the volume and surface area. Cylinder () is use only for computations. Sample Output Enter the radius of

Have the user input 5 numbers and outputs witch numbers are prime


Use the functions char toUpper(char) to check if a char is a lowercase alphabetic value. If it is, return the uppercase equivalent. If it isn’t, return the original char.


Assignment: Functions


void printBanner() – This function should open the file “banner.txt” in the same directory as the program, and print it’s contents to the terminal. It does not depend on any other functions.


Assignment: Functions


double s_to_d(string) – Converts a decimal number saved as a string to a decimal number saved as a float. Follows the given steps.

1. Create a double accumulator.

2. Find the index i of the decimal point (‘.’).

1. If no decimal point exists, set i to the length of the string.

3. Iterate over each character in the string with the iterator j.

1. If i – j is positive,

1. Pass the current character into c_to_i(char)

2. raise 10 to the power of the i – j – 1 with the myPow(int, int) function.

3. multiply these two results.

4. Add this result to the accumulator.

2. else if i – j is negative,

1. Pass the current character into c_to_i

2. raise 10 to the power of i – j.

3. multiply these two results.

4. Add this result to the accumulator.

4. Return the accumulator.


Assignment: Functions

char toUpper(char) – checks if a char is a lowercase alphabetic value. If it is, return the uppercase equivalent. If it isn’t, return the original char. Depends on no other functions.


string toUpper(string) – iterates over each character in the string and capitalizes it with the toUpper(char) function. Depends on the toUpper(char) function.


string fixNum(string) – returns a string with the following replacements made to the string argument:

Before: After:

O 0

I 1

E 3

S 5

aa 7


int c_to_i(char letter) – Checks if a char is numeric. If it is, return the integer equivalent. If it is not, return -1. Depends on no other functions.


double myPow(int, int) – Returns the first argument raised to the power of the second argument. (Be careful, this function should work for all positive and negative integers).



Assignment:


void printBanner() – This function should open the file “banner.txt” in the same directory as the program, and print it’s contents to the terminal. It does not depend on any other functions.


void showMenu() – This function should print a menu to display the following options:

1. Enter an input file

2. Enter an output file

3. Clean input file

4. Quit

It does not depend on any other functions.


string getInputFile() – prompts the user for an input file name. Returns the user’s choice as a string. This function does not depend on any other functions.


string getOutputFile() – prompts the user for an output file name. Returns the user’s choice as a string. This function does not depend on any other functions.


Question 5 [15 Marks] Write a C++ programme to create a class by name Book Data Members of the class BOOK are BOOK_NO integer BOOK_NAME 20 characters BOOK_PRICE float TOTAL_COST() Calculate the cost of N books where N is passed as an argument. Member Functions of the class BOOK are INPUT() function to read BOOK_NO. BOOK_NAME, BOOK_PRICE PURCHASE() Get an input for the number of copies to be purchased. It uses TOTAL_COST() function to calculate the cost of N books and prints the total cost to be paid by the user. Create the necessary object for this class to run this program effectively. (Implement the OOPS concepts Polymorphism, inheritance, and Friend function wherever it is necessary) Question 6
LATEST TUTORIALS
APPROVED BY CLIENTS