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

Write a C++ program called PositiveNumbers.cpp.

The program must do the following:

 Prompt user to enter a positive number that is greater than 0 or a -1 to quit (See Figure 4.1).

NB: Make use of a post-test loop

 If the number is within the range, determine the following :

o how many numbers are entered,

o the total (sum) of all numbers entered,

o determine how many are even numbers and,

o determine the highest number entered.

 If the number is invalid display and appropriate message as indicated in Figure 4.2.

 This process must be repeated until an invalid number is entered (-1).When the process terminates, display the following (See Figure 4.1 and Figure 4.3)

o the total of the numbers entered,

o the total number of even numbers,

o the highest number and

o the sum of all numbers entered.


Make a c++ program of a simple menu program of the sample run below.


Sample Run:


Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 1

 You picked Easy.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 2

You picked Normal.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 3

 You picked Hard.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 4

Illegal Choice. Please try again.

Play another game? (y/n): y

Difficulty Levels

      1. - Easy

      2. - Normal

      3. - Hard

Choice : 2

You picked Normal.

Play another game? (y/n): n

Thanks for playing…

This terminates the process.

[ So, this portion the cycles repeat until expression test false,

 at which point the loop ends.]


1.A student with a temperature from 36.5°C to 37°C will be allowed to write their exams. The value of the students’ temperature will be stored in variable called temperature.


1.1 Write a C++ while clause that will allow the program to execute when the value in the temperature variable is within the required range.

1.2 Which data type of data is the student’s temperature.


1. Consider the for-loop statement in pseudocode below and answer the following questions number = 15

do while (number >=-25)

Display “number = “, number

number = number -2

Loop


1.1 Rewrite the do while loop using a for-loop in a C++ syntax. Write only the for loop statement, do not write the other instructions inside the body of the loop.

1.2 Rewrite the do while loop above in C++ syntax.

1.3 How many times will the loop execute?

1.4 The value of number after execution of the loop.


1.1 Which of the following program segments will display odd numbers up until to 31?

a. i = 1;

while (i < 31)

{ cout << "i = " << i << endl; i = i + 2; }

b. for(int i= 0; i < 32 ; i++)

{ cout << "i = " << i << endl; }

c. for(int i= 0; i <= 31 ; i= i + 2 )

{ cout << "i = " << i << endl; }

d. for(int i= 1; i < 32 ; i= i + 2 )

{ cout << "i = " << i << endl; }


1.1 A variable declared within the for-loop has _________ scope.

a. local

b. global

c. block

d. private

1.2 Which of the following statements is equivalent to the following: while (value < 18)

a. while (value <= 18)

b. while (value >=18)

c. while (! (value > 18) )

d. while (value < 17)

1.3 Which of the following equations will deduct a discount of 7.5% from an amount?

a. amount = amount – 7.5%

b. amount = amount * .925;

c. amount = amount – (amount * 0.075)

d. amount = amount – amount * 0.75;

1.4 Which of the following statement is equivalent to?

result *= a + 5;

a. result = result * a + 5;

b. result = result * (a + 5);

c. result = (result * a ) + 5

d. results = a+ 5;



WAP to create 3 Classes. Each class must have input function (to input one value from user) and display function. Make a common friend function of three class that find greatest number.


A stationary store uses a system to generate the customer purchase amount. The cashier needs to key in the item code and item quantity. Then, the system calculates the purchase amount and generate a receipt for the customer. Information on item code, item name, item description, item quantity, item price and purchase amount will be printed on the receipt. 



There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 inputted values and print out the result.


Go and search for the positive ones among these four!


Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong".


LATEST TUTORIALS
APPROVED BY CLIENTS