Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 11 Weeks Ago, 1 Day Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
A high school senior is applying for colleges. He wants a program to calculate the out-of-pocket cost for attending each college he is applying. The out-of-pocket cost is determined by the following formula:
Â
out-of-pocket cost = tuition + room + board + other expenses – financial aid
Â
Write a program to calculate the out-of-pocket cost of every college he is applying. After each college, ask the user whether to calculate cost for another college. Enter ‘y’ for yes. The following is an example:
Â
Enter name of college: Wake Tech
Enter tuition: 8500
Enter room: 6000
Enter board: 4000
Enter other expenses: 3000
Enter financial aid: 2000
Out-of-pocket cost for this college: 19500
Calculate cost for another college? [y/n] y
Â
Enter name of college: Jefferson College
Enter tuition: 35000
Enter room: 7000
Enter board: 4500
Enter other expenses: 5000
Enter financial aid: 22000
Out-of-pocket cost for this college: 29500
Calculate cost for another college? [y/n] y
Â
Enter name of college: Freedom University
Enter tuition: 20000
Enter room: 10000
Enter board: 5000
Enter other expenses: 5000
Enter financial aid: 30000
Out-of-pocket cost for this college: 10000
Calculate cost for another college? [y/n] n
Â
Save your Python program in a file named Lab04P1.py. Submit the file to Blackboard for credit.
Â
Problem 2
 Â
We wrote the following program to calculate BTU needed to cool a room.
Â
roomLength =Â float(input('Enter room length: '))
roomWidth =Â float(input('Enter room width: '))
roomHeight =Â float(input('Enter room height: '))
roomVolume = roomLength * roomWidth * roomHeight
btuNeeded = roomVolume *Â 3.5
print('BTU needed for this room:', btuNeeded)
Â
Modify the program by adding error checking loops. Room length, width and height must all be greater than 0. Every time the user enters a negative number, display an error message and ask the user to re-enter a valid value immediately.Â