__Fundamentals of programming__

Question 1:

Write an algorithm and then a
C++ program that asks the user to enter temperature of type double and if the
temperature entered is greater than the normal temperature (given by the
programmer) then the program must calculate the degrees of fever by subtracting
normal temperature from the temperature given by user.

Question 2:

Draw the flow Chart on a
paper before writing program.

Write a complete C++ program
of the following illustrations.

A user purchased certain items;
if the items purchased are greater than zero then average cost of the item will
be calculated and displayed with appropriate message otherwise appropriate
error message must be displayed.

The program will contain
three variables num_Items, average_Cost and

total_Cost of type integer
and real respectively. Assign appropriate values to num_Items and total_Cost
and then perform the task given above.

Question3:

What is wrong with the following if statement (there
are at least 3 errors). The indentation indicates the desired behavior. (Check
it either manually or by writing the whole code in a C++ source file in a
complete C++ program)

if numNeighbors >= 3 || numNeighbors = 4

++numNeighbors;

cout << "You are
dead!" << endl;

else

--numNeighbors;

Question4:

Write if statements to do the following:

Ø If character variable tax Code is ’T’, increase price
by adding the taxRate per-centage of price to it.

Ø If integer variable opCode has the value 1, read in or
input double values for X and Y and

calculate and print their sum.

Ø If integer variable test is even or odd.

Ø If integer variable current Number is odd, change its
value so that it is now 3

times currentNumber plus 1, otherwise
change its value so that it is now half of

currentNumber

Ø If integer variable Number is multiple of 3 or not

Ø Assign 1 to the integer variable leapyYear if the
integer variable year is a

leap year. (A leap year is a multiple of
4, and if it is a multiple of 100, it must

also be a multiple of 400.)

Ø Assign a value to double variable cost depending on
the value of integer variable

distance as follows:

Distance Cost

-----------------------------------
------------------

0 through 100 5.00

More than 100 but not more
than 500 8.00

More than 500 but less than
1,000 10.00

1,000 or more 12.00