Details
This set of problems and coding challenges are to be done in lab and at home.
All the cpp files from this assignment should be in a folder.
The name of the folder should follow this format:
lastName_firstName_#2
For example, my name is Alex Chen, folder name will be "Chen_Alex_#2"
Failure to follow this naming convention will result in your assignment not being graded.
The folder is to be zipped and submitted on blackboard on the due date.
#1
Write a checkout.cpp program that does the following:
- Ask the user to enter the price of their items. The user can enter as many items as they want until the user enters the integer 0.
- Print out the total of their checkout.
- If the sum is greater than $100, print out "Thats Expensive!"
#2
Write a reverse.cpp program that does the following:
- It asks the user to enter an integer between 100 and 9999.
- If the entered number is out of range, the program forces the user to enter more numbers until one in the correct range is given.
- Then the program prints the digits in the number (in reverse) on separate lines.
Enter an integer between 100 and 9999: 8976
6
7
9
8
#3
Write a triangle.cpp program that does the following:
- It asks the user to enter a positive integer.
- The program reads a value x entered by the user. If the value is not legal, the program repeatedly makes the user type in another value until a legal value of x has been entered.
- The program prints a triangular display which has the number x on its top row. Each later row is obtained by omitting the last digit from the number on the previous row.
19683
1968
196
19
1
#4
Write a reverseSum.cpp program that does the following:
- It asks the user to enter a positive integer.
- If the input is illegal, the program should terminate.
- The program prints the digits of the number in reverse order (separated by spaces) and then gives their sum.
3 8 6 9 1 sum to 27
#5
Write a oddCount.cpp program that does the following:
- Ask the user to enter an integer between 1000 and 1000000
- If the user enters an invaild input ask the user to try again. The user only has 3 tries. If they fail all 3 times, terminate the program
- The Program prints out the number of odd numbers in that integer
#6
Write a big.cpp program that does the following:
- Ask the user to enter a positive integer with at least 2 digits.
- If the user enters an invalid input, ask to try again.
- Print out the biggest integer in the user's number
#7
Write a factor.cpp program that does the following:
- Ask the user to enter a 2-digit number, and store it as an int.
- If the input is not a 2-digit number, repeatedly ask the same question until the user enters a 2-digit number.
- Print all positive factors of the number, in ascending order, one per line. A number i is a factor of n if when you divide n by i, the remainder is 0.
- Then print the total number of factors.
Enter a 2-digit number: 15
Factors:
1
3
5
15
15 has 4 factors.
#8
Write a star.cpp program that does the following:
- Ask the user to enter a number divisible by 10
- If the user enters an invalid input, terminate the program
- Divide the input by 10 and store the answer in a variable x
- Print out x number of rows of 10 "*"
**********
**********
**********
**********
**********