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

Include the for loop below in a small program and complete the program. The loop should execute 10 times. Do

not change the for loop below. Compile and run your program to see for yourself that it works. You do not have

to submit this program and output.

for (int i = 1; i <= n; i++)

cout << i * i;

Now convert the for loop into a while loop and add any variable initialisations that you think are necessary.

Compile and run your program and submit only the program containing the while loop and its output.


The Computer Science Department follows certain criteria when a student learns to program. A number of

programming exercises must be worked through. To proceed to the next exercise a student has to obtain a mark

of 50% or more and must have completed 5 or more program runs. You are requested to write a program to validate

if a student can proceed to the next program.

Your program should have the following structure:

 Declare two integer variables programsDone and result.

 Validate the data captured for the two variables using a while loop.

 The loop should be repeated until the value of result is greater than or equal to 50 and the value of

programsDone is greater than or equal to 5.

 Display a message like "Good! You can now proceed to the next exercise"


You are requested to write a very simple calculator. Your calculator should be able to handle the five basic

mathematic operations – add, subtract, multiply, divide and modulus – on two input values.

18

Your program should have the following structure:

 Ask the user to enter two float variables named var1 and var2

 Ask the user to enter a character variable named operation to represent the operation to be performed

on the two variables.

 Perform the appropriate operation by using if-statements

 The output must be given in fixed-point notation with two digits after the decimal point.

A typical run is displayed below:

Please enter the first float value: 35.6

Please enter the second value: 24.12

Please enter the operation required : +

The sum of 35.6 and 24.12 is 59.72


Find a good cookbook. Read the instructions for your favourite dish. Write a program to display the recipe on the

screen but with a difference. The quantity of each ingredient must be multiplied by a value entered from the

keyboard.

For example, if the recipe needs 2 cups of flour the output displayed will be something like this

Please enter the factor to multiply the ingredients with : 4

Recipe name

Ingredients

// other ingredients

8 cups flour

Method

The program has the following structure:

 Declare an int variable named mFactor to store the value with which the quantity of each ingredient

must be multiplied.

 The program must make use of a cin statement to input a value from the keyboard and store it in mFactor.

Submit both your program and output.


Question 5 [15 Marks) Write a C++ programme to create a class by name Book Data Members of the class BOOK are BOOK_NO BOOK_NAME BOOK_PRICE integer 20 characters float TOTAL_COST() Calculate the cost of N books where N is passed as an argument Member Functions of the class BOOK are INPUTO 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) QP

Create a program that calculates the cost of building a desk. The main() function calls four other functions. Pass all variables so that the function makes copies of any variables they receive:


Design an algorithm which generates even numbers between 1000 and 2000 and then prints them in the standard output. It should also print total sum.

Write a program that will display a calendar given a month and year as an input to the program. Will display only single month of year given. Here it’s that if given input as ( April 2003) will display only the given month of the year.


Write a program that simulates



a simple cash register. It should ask the user if a customer is to be



processed. If the user responds yes, prompts the user to enter the



price of the meal. Then it calculates the sales tax (8% of the meal price)



and the total price, which it should display to the user. Next, it asks the



user to enter the amount tendered, and displays the amount tendered, the total



price, and the customer’s change. The program then asks the user if there is



another customer to process. If the user responds yes, the program processes the



next customer in the same way. This procedure continues indefinitely until the



user responds no to the prompt for another customer. Finally, the program



displays the total number of customers it processed and the grand total of all the



meal prices. Input Validation: Do not accept a number less than 1 for the price of the meal. Do not accept a value for the amount tender that is less than the total price.



The screen size of a TV is given by the length of the rectangular diagonal. Traditional TVs come in 4:3 ratio, that is, the ratio of length to width is 4 to 3. This means, if the length is x inches, then the width is (3/4)x. LCD TVs come in 16:9 ratio. Write a program that prompts the user to input the length of the diagonal (in inches) of the screen and allows the user to select which type of TV’s screen length, screen width and screen area the user would like to calculate. Have the program display the desired results. 


LATEST TUTORIALS
APPROVED BY CLIENTS