C++ Answers

Questions answered by Experts: 9 913

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

Define a class called CUSTOMER with the following members name_of_the_customer type_of_loan number_of_months principal_amount EMI There are 3 member functions. First one to set the value for name_of_the_customer, number_of_months, principal_amount and type_of_loan. Second one to print all the data members. Third function to calculate EMI and it is calculated as follows. If type_of_loan is “bike” then monthly interest rate is 9.2%. If type_of_loan is “Home” then monthly interest rate is 7.35%.


The diameter of a cycle wheel is D. Given that, the cycle travels at an average speed of X km/h,

find the number of revolutions made by the wheel per minute, giving your answer to the nearest whole

number (assume PI = 3.142). Write a C++ function to calculate revolutions per minute.


Sample Run 1

Welcome to CS126 Mart!

Item Codes Description Price

100 Sweet ‘n Ripe Grapes 125.35

101 Crunchy Apples 52.20

109 Green Peas 25.75

Enter Code: 128

Invalid code, please enter a valid one.


Enter Code: 100

Sweet ‘n Ripe Grapes 125.35

Quantity -3

Invalid Quantity, please enter again.

Quantity 2

Subtotal: 250.70


Enter Code: 101

Crunchy Apples 52.20

Quantity 1

Subtotal: 52.20


Enter Code: 0

Total Amount Due: 302.90

Cash: 100.00

Insufficient Cash!

Cash: 1000.00

Change: 697.10


=========== CHANGE BREAKDOWN ===========

1000 0 0

500 1 500.00

200 0 0

100 1 100.00

50 1 50.00

20 2 40.00

10 0 0

5 1 5.00

1 2 2.00

0.25 0 0

0.10 1 0.10

0.05 0 0


Do you want another transaction? <y/n> No.


Sample Run 1

Welcome to CS126 Mart!

Item Codes Description Price

100 Sweet ‘n Ripe Grapes 125.35

101 Crunchy Apples 52.20

109 Green Peas 25.75

Enter Code: 128

Invalid code, please enter a valid one.


Enter Code: 100

Sweet ‘n Ripe Grapes 125.35

Quantity -3

Invalid Quantity, please enter again.

Quantity 2

Subtotal: 250.70


Enter Code: 101

Crunchy Apples 52.20

Quantity 1

Subtotal: 52.20


Enter Code: 0

Total Amount Due: 302.90

Cash: 100.00

Insufficient Cash!

Cash: 1000.00

Change: 697.10


=========== CHANGE BREAKDOWN ===========

1000 0 0

500 1 500.00

200 0 0

100 1 100.00

50 1 50.00

20 2 40.00

10 0 0

5 1 5.00

1 2 2.00

0.25 0 0

0.10 1 0.10

0.05 0 0


Do you want another transaction? <y/n> No.


Write a Program: Print a table of stars and zeroes 

print a square table of alternating stars and zeroes. 


Ask the user to enter a size of the table. The number should be odd. Since the table is square the number of rows and columns will be the same and should be equal to the entered size. The valid range for the size is from 3 to 15, inclusive. 


Use a loop to make sure the entered size is odd and within the range. Output a descriptive error message if an invalid size is entered. The error message should indicate if the size is even, or less than the minimum, or larger than the maximum. 




Each row in said table should have ‘*’ and ‘0’ symbols separated by a space. Each column of the table should also have alternating ‘*’ and ‘0’ symbols. All corners should have the ‘*’ symbol.

enter an odd size from 3 to 15: 3


* 0 *

0 * 0

* 0 *





Exercise 3: Practice to manipulate data in arrays Write a C program to create an integer array called Motion of size 5. Ask the user to enter values to the array from the keyboard. Rotate the values of the array by one position in the forward direction and display the values.

Ex: number in index 4 should move to index 3, Number in index 3 should move to index2, number index 0 should move to index 4.

Initial values 10 6 8 2 9

After rotating 6 8 2 9 10


Exercise 1: Practice to store and print data in an array

a) Write a C program that reads marks of 10 students in to a single subscripted array.

b) Above marks should be between 0 to 20. Modify the above program to add marks to the array only if the input mark is between the given range.

c) Display the values stored in the array.


Implemented using while loop
Enter first number: 5
Enter second number: 10
Sum of all even number: 24
Sum of all odd number: 21
5 square is 25
6 square is 36
7 square is 49
8 square is 64
9 square is 81
10 square is 100
Sum of squares of all the numbers: 355


How to get an output like this Using while loop?
How can I fix the error there of
Cin>> choice;
If (choice !='y')

And

Cout<<"pay the fare:";
Cin>> pay;

Since it says both are not declared in this scope.

Pleas help

You should now have a complete working program that converts a given temperature from Fahrenheit to Celsius and vice versa, depending on which option (integer) the user enters.


Revise your temperature converter to use a switch statement. The switch should test a char variable holding the characters entered by the user, e.g: Enter "f" to convert from Fahrenheit to Celsius Enter "c" to convert from Celsius to Fahrenheit


You should provide an appropriate default statement.


LATEST TUTORIALS
APPROVED BY CLIENTS