Uploaded by Sasa Mohamed

Ass-2-1001-W21

advertisement
Department of Computer Science & Engineering
CSCE 1001-03
Assignment 2
1.
Write an algorithm which is a mixture between English and C++ code to find the
product of a collection of data values and return that product. Your algorithm
should ignore any negative data and should terminate when a zero value is read.
Then write the C++ function implementing the algorithm
2.
Write a program to read a number of students’ grades and print out the greatest grade.
3.
Write a program that allows the user to enter a four-digit number. It then calculates and
prints the sum of all the digits in the number, and the new sum after removing a single
digit from the extreme right side of the number. It continues this process until the original
number becomes a single digit. For example if the user enters 2345 the program should
output this:
Sum of digits of number 2345 is fourteen
Sum of digits of number 234 is nine
Sum of digits of number 23 is five
Sum of digits of number 2. is two
Design your program with three functions. One for removing a single digit of the
remaining number starting from extreme right, one for summing the digits of the integer
number , and one for converting the integer number to an English word. This will convert
only numbers until 15 into English word. If the number exceeds 15 it output a string
indication that the number is greater than15. The digits summation function must have
two arguments, one for the current digits remaining in the number and the second for the
number of these digits.
4.
A liter is 0.264179 gallons. Write a program that will read the number of liters of gasoline
consumed by the user’s car and the number of miles travelled by the car and then will
output the number of miles per gallons the car delivered. Design this program to have
three functions in addition to the main. The first function is to read the input data described
here above. The second function is to compute the number of miles per gallon. The third
function is to display the data entered by the user and the output of the second function
in a nice format. The main function is to run continuously asking for inputs from the user
and display results by calling the appropriate functions until the user enters negative
numbers for the liters of gasoline and number of miles. Your program should use a
globally defined constant for the number of liters per gallon.
Download