Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Overview You will write a program that will use a while loop to prompt a user for first _ num and second _ num, divide
Overview
You will write a program that will use a while loop to prompt a user for firstnum and secondnum, divide firstnum by secondnum and store the result in a variable called answer, and then print it out cleanly. Your program should handle the divide by zero error and no other errors and should make use of a tryexeceptelse block. It should continue until the user enters a q
Expected Output
Example
What is the first number? or type q to quit
What is the second number?
is
What is the first number? or type q to quit
What is the second number?
You cannot divide by zero
What is the first number? or type q to quit
What is the second number?
is
What is the first number? or type q to quit q
The program is over
Specifications
You should submit a single file called MApy
It should follow the submission standards outlined here: Submission Standards
Your program must use a whileloop to collect user input until the user enters q
Your program must store the user input in variables called firstnum and secondnum and must store the calculation in a variable named answer.
Your program must catch the error of dividing by zero only using a tryexcecptelse block
Tips and Tricks
Besides the error handling casting is key to this one. Make sure you are converting variables to the type you need when you need it
HardCoded
Nothing is hardcoded for this file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started