CSC / CIS 175 Problem Solving and Programming – I Homework 3

$40.00

Category: Tags: , , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (3 votes)

1. Write a program that reports whether a number input is divisible by 7.
Hint: If a number is divisible by 7, that means you can divide it by 7 and get a remainder
of 0.
Test Data:
(i)
Enter an integer number : 79
Your integer number: 79 is not divisible by 7
(ii)
Enter an integer number : 28
Your integer number: 28 is divisible by 7
2. Write a program that reads two integers from the keyboard and prints if the first is a multiple
of the second. Hint: Use modulus operator.
Test Data:
(i)
Enter the first integer : 23
Enter the second integer : 58
23 is NOT evenly divisible by 58
(ii)
Enter the first integer : 240
Enter the second integer : 3
240 is evenly divisible by 3
3. Modify the hw1, q1 program so that it prints out the letter grade based on the grading scale
of this class available on the syllabus.
Test Data:
(i)
Please enter points scored in Homework 1 :59
Please enter points scored in Homework 2 :59
Please enter points scored in Homework 3 :59
Please enter points scored in Mid-Term :59
Please enter points scored in Final :59
Hw1 Hw2 Hw3 Mid-Term Final Total
59 59 59 59 59 59
Overall Grade: 59 out of 100
Your letter grade is : F
(ii)
Please enter points scored in Homework 1 :97
Please enter points scored in Homework 2 :97
Please enter points scored in Homework 3 :97
Please enter points scored in Mid-Term :97
Please enter points scored in Final :97
Hw1 Hw2 Hw3 Mid-Term Final Total
97 97 97 97 97 97
Overall Grade: 97 out of 100
Your letter grade is : A+
(iii)
Please enter points scored in Homework 1 :80
2
Please enter points scored in Homework 2 :90
Please enter points scored in Homework 3 :70
Please enter points scored in Mid-Term :50
Please enter points scored in Final :80
Hw1 Hw2 Hw3 Mid-Term Final Total
80 90 70 50 80 71
Overall Grade: 71 out of 100
Your letter grade is : C4. Write a program that inputs three integers from the keyboard and prints the sum, average,
product, smallest and largest of these numbers.
Test Data:
(i)
Please enter Integer 1 : 24
Please enter Integer 2 : 34
Please enter Integer 3 : 54
Sum of 24, 34 and 54 is 112
Average of 24, 34 and 54 is 37
Product of 24, 34 and 54 is 44064
Smallest of 24, 34 and 54 is 24
Largest of 24, 34 and 54 is 54
(ii)
Please enter Integer 1 : 5
Please enter Integer 2 : 1
Please enter Integer 3 : 9
Sum of 5, 1 and 9 is 15
Average of 5, 1 and 9 is 5
Product of 5, 1 and 9 is 45
Smallest of 5, 1 and 9 is 1
Largest of 5, 1 and 9 is 9
3
5. Write a program that reads in the quiz scores of a class of ten students. The grades are
integers in the range of 0-100. If the grade entered is not within this range, reject and ask
for a number in the range. Calculate and display the total of all student grades and calculate
the average.
Extra Credit (10%): Calculate the standard deviation. Use only what we have so far learned
in class about c++. YOu may need to do some lookup for standard deviation.
Test Data: (with the extra credit. If you don’t want to do the extra credit, ignore
the std and var parts).
(i)
Quiz Score #1 : 50
Quiz Score #2 : 60
Quiz Score #3 : 70
Quiz Score #4 : 80
Quiz Score #5 : 90
Quiz Score #6 : 100
Quiz Score #7 : 50
Quiz Score #8 : 60
Quiz Score #9 : 70
Quiz Score #10 : 80
Total is 710
Avg is 71
Variance is 249
Std Var is the square root of variance
(ii)
Quiz Score #1 : 101
Out of range, re-enter
Quiz Score #1 : -4
Out of range, re-enter
Quiz Score #1 : 50
Quiz Score #2 : 60
Quiz Score #3 : 70
Quiz Score #4 : 120
Out of range, re-enter
Quiz Score #4 : 80
4
Quiz Score #5 : 90
Quiz Score #6 : 100
Quiz Score #7 : 50
Quiz Score #8 : 60
Quiz Score #9 : 70
Quiz Score #10 : 80
Total is 710
Avg is 71
Variance is 249
Std Var is the square root of variance
6. Write a program that displays the following menu:
Geometry Calculator
1. Calculate the Area of a Circle
2. Calculate the Area of a Rectangle
3. Calculate the Area of a Triangle
4. Quit
Enter your choice (1-4):
If the user enters 1, the program should ask for the radius of the circle and then display its
area. Use 3.14159 for π. If the user enters 2, the program should ask for the length and width
of the rectangle, and then display the rectangle’s area. If the user enters 3, the program
should ask for the length of the triangle’s base and its height, and then display its area. If
the user enters 4, the program should end. Input Validation: Display an error message if the
user enters a number outside the range of 1 through 4 when selecting an item from the menu.
Do not accept negative values for the circle’s radius, the rectangle’s length or width, or the
triangle’s base or height.
Expected Output:
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
5
Enter your choice (1-4): 1
Enter the circle’s radius: -3
The radius can not be less than zero.
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 1
Enter the circle’s radius: 4
The area is 50.2654
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 2
Enter the rectangle’s length: -4
Enter the rectangle’s width: 5
Only enter positive values for length and width.
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 2
6
Enter the rectangle’s length: 5
Enter the rectangle’s width: 7
The area is 35
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 3
Enter the length of the base: 9
Enter the triangle’s height: -4
Only enter positive values for base and height.
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 3
Enter the length of the base: 5
Enter the triangle’s height: 6
The area is 15
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 4
7
Bye!
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>hw3-q6.exe
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 8
You may only enter 1, 2, 3, or 4.
R:\yuva\teaching\UMF\CSC175\W2010\Homeworks\hw3>
8
Deliverables:
1. Source Code: (.cpp file) that must start with a comment block similar to the following:
/*************************************************************************
** Author : Suleyman Uludag
** Program : hw1, q1
** Date Created : September 15, 2013
** Date Last Modified : September 16, 2013
** Usage : No command line arguments
**
** Problem:
Accept the following information from the user (keyboard):
– Hw1, hw2 and hw3 (out of 100)
– Midterm (out of 100)
– Final exam (out of 100)
Calculate the total grade out of 100 based on the following grading scale:
Hws –> 30% (10% each)
Midterm –> 30%
Final Exam –> 40%
** Pseudocode:
** 1)
** 2)
*************************************************************************/
2. Executable (.exe file under windows). You must explicitly state the platform of your executable (such as Linux, etc.) if it is not Windows. Please name your file by using the
question number: hw1-q1.exe (for Windows)
3. Screenshot of your app. For screenshot, you can use the following free program on windows:
http://www.wisdom-soft.com/downloads/setupscreenhunterfree.exe
For Linux/Unix, there are many alternatives. I personally like shutter.
File naming convention example:
hw1 q1.png (or .jpg or another graphics format)
4. You must zip all the above three files into ONE .zip file and submit your assignment by the
deadline on moodle system. Name your file as Lastname-Firstname-hw#.zip. For example,
Uludag-Suleyman-hw1.zip
For generating .zip file, you may use the following free software on Windows:
http://www.7-zip.org/download.html
Linux/Unix has many built-in.
9