Question: Write a program to convert a fraction to a decimal. Have your program ask for the numerator first, then the denominator. Make sure to check

Write a program to convert a fraction to a decimal. Have your program ask for the numerator first, then the denominator. Make sure to check if the denominator is zero. If it is, print out "Cannot divide by zero."
Hint: Since this lesson uses if-else statements, remember to use at least one if-else statement in each of your answers to receive full credit.
Sample Run 1
Enter the numerator: 2
Enter the denominator: 0
Sample Output 1
Cannot divide by zero.
Sample Run 2
Enter the numerator: 4 Enter the denominator: 5
Sample Output 2
Decimal: 0.8
Write a program to convert a fraction to a decimal. Have your program ask for the numerator first, then the denominator. Make sure to check if the denominator is zero. If it is, print out "Cannot divide by zero."
Hint: Since this lesson uses if-else statements, remember to use at least one if-else statement in each of your answers to receive full credit.
Sample Run 1
Enter the numerator: 2
Enter the denominator: 0
Sample Output 1
Cannot divide by zero.
Sample Run 2
Enter the numerator: 4 Enter the denominator: 5
Sample Output 2
Decimal: 0.8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!