Starting from:

$29

Homework 1 Printf, Scanf, Conditionals, and Operators

Homework 1 
Homework #1:
For the first assignment I want you to use the concepts that we have learned so far. Printf, Scanf, Conditionals, and Operators.
The first part is to do some fraction math. I want you to have the user input 2 different fractions. Each fraction will be input in the form of "a/b"
where a and b are both positive integers. For each fraction you will store them in 2 integers (numerator and denominator). The operations you will
be required to do are addition, subtraction, multiplication, and division.
After you do this, I want you to use a conditional statement to find out whether the first fraction is a improper fraction or not. If it is an improper
fraction, print that it is and print it as a mixed number (make sure if the fraction is 0/b after doing the mixed number don't print the fraction part).
This will require nesting conditionals. Otherwise, say it is a proper fraction.
After this, give me the decimal approximation of the first fraction to 2 decimals of precision. Remember what I have said about type casting.
The final thing you will do is ask the user for one last integer for a GPA grade. With this integer you will use a switch statement to print out what
the letter grade would be.
Here is what you would print:
4 - You got an A!
3 - You got an B!
2 - You got an C!
1 - You got an D!
0 - You got an F!
Anything else - That isn't a grade
Remember. Document your code. DOCUMENT WELL. I'll be grading you on how meaningful your comments are. Also, use appropriate variable
names. Not saying they need to be 50 characters long, but make sure they tell the person reading the code the purpose. I will be grading you on
the correctness (meeting these specifications), design, documentation, and efficiency (which should be easy on this first homework).
Here is some sample input/output. I want your prints and scans to follow the same form as mine. Use the same words for printing.
Enter Fraction 1: 3/5 3/5
Enter Fraction 2: 2/7 2/7
Fraction Number 1: 3/5
Fraction Number 2: 2/7
Addition of Fractions: 31/35
Subtraction of Fractions: 11/35
Multiplication of Fractions: 6/35
Division of Fractions: 21/10
Fraction 1 is a proper fraction
Decimal Approximation of Fraction 1: 0.60
Enter in a GPA for the class (0-4 integer): 33
You got an B!
Enter Fraction 1: 15/5 15/5
Enter Fraction 2: 4/3 4/3
Homework 1 5/18/16, 3:15 PM
https://usflearn.instructure.com/courses/1112240/assignments/4630571#submit Page 2 of 2
Fraction Number 1: 15/5
Fraction Number 2: 4/3
Addition of Fractions: 65/15
Subtraction of Fractions: 25/15
Multiplication of Fractions: 60/15
Division of Fractions: 45/20
Fraction 1 is an improper fraction
Fraction 1 as a Mixed Number: 3
Decimal Approximation of Fraction 1: 3.00
Enter in a GPA for the class (0-4 integer): -4-4
That isn't a grade
Enter Fraction 1: 19/7 19/7
Enter Fraction 2: 3/7 3/7
Fraction Number 1: 19/7
Fraction Number 2: 3/7
Addition of Fractions: 154/49
Subtraction of Fractions: 112/49
Multiplication of Fractions: 57/49
Division of Fractions: 133/21
Fraction 1 is an improper fraction
Fraction 1 as a Mixed Number: 2 5/7
Decimal Approximation of Fraction 1: 2.71
Enter in a GPA for the class (0-4 integer): 44
You got an A!
Upload a file, or choose a file you've already uploaded.
File: Choose File no file selected
Add Another File
Click here to find a file you've already uploaded
Comments...
File Upload Google Doc
Cancel Submit Assignment

More products