Section 3
.pdf
keyboard_arrow_up
School
Southern New Hampshire University *
*We aren’t endorsed by this school
Course
140
Subject
Computer Science
Date
Apr 3, 2024
Type
Pages
2
Uploaded by DeaconCaterpillar4154
3.13 LAB: Exact change
Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin
type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as
appropriate, like 1 Penny vs. 2 Pennies.
Ex: If the input is:
0 (or less than 0), the output is:
No change Ex: If the input is:
45
the output is:
1 Quarter
2 Dimes 553398.3976864.qx3zqy7
LAB
ACTIVITY
3.13.1: LAB: Exact change
10 / 10
When done developing your program, press the Submit for
grading
button below. This will submit your program for
auto-grading.
Coding trail of your work
3/25
M
-10
min:0
Latest submission - 1:54 AM EDT on
03/25/24
Submission passed
all tests
Total score: 10
/ 10
Only show failing tests
1:Compare output
2 / 2
Input
45
Your output
1 Quarter
2 Dimes
2:Compare output
2 / 2
Input
0
Your output
No change
3:Compare output
2 / 2
Input
156
Your output
1 Dollar
2 Quarters
1 Nickel
1 Penny
4:Compare output
2 / 2
Input
300
Your output
3 Dollars
5:Compare output
2 / 2
Input
141
main.py
Load default template...
print
(
Dollars
)
if num_quarters > 0:
print
(
str
(
num_quarters
), end
=
""
)
if num_quarters == 1:
print
(
" Quarter"
)
else
:
print
(
" Quarters"
)
if num_dimes > 0:
print
(
str
(
num_dimes
), end
=
""
)
if num_dimes == 1:
print
(
" Dime"
)
else
:
print
(
" Dimes"
)
if num_nickels > 0:
print
(
str
(
num_nickels
), end
=
""
)
if num_nickels == 1:
print
(
" Nickel"
)
Develop mode
Submit mode
Submit for grading
What is this?
Download this submission
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Your output
1 Dollar
1 Quarter
1 Dime
1 Nickel
1 Penny
Feedback?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Python all info is there
arrow_forward
3.12 LAB: Seasons
Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day.
Ex: If the input is:
April 11
the output is:
Spring
In addition, check if the string and int are valid (an actual month and day).
Ex: If the input is:
Blue 65
the output is:
Invalid
The dates for each season are:Spring: March 20 - June 20Summer: June 21 - September 21Autumn: September 22 - December 20Winter: December 21 - March 19
247772.2002516.qx3zqy7
arrow_forward
3.4 LAB: Seasons
Write a program that takes a date as input and outputs the date's season in the northern hemisphere. The input is a string to represent th
month and an int to represent the day. Note: End with a newline.
Ex: If the input is:
April 11
the output is:
Spring
In addition, check if the string and int are valid (an actual month and day)
Ex. If the input is
Blue 65
the output is
Invalid.
The dates for each season in the northern hemisphere are:
Spring: March 20-June 20
Summer June 21-September 21
Autumn September 22- December 20
Winter December 21- March 19
arrow_forward
PP 6.4 Write a program that prints the first few verses of the traveling
song “One Hundred Bottles of Beer." Use a loop such that each
iteration prints one verse. Read the number of verses to print
from the user. Validate the input. The following are the first two
verses of the song:
100 bottles of beer on the wall
100 bottles of beer
If one of those bottles should happen to fall
99 bottles of beer on the wall
99 bottles of beer on the wall
99 bottles of beer
If one of those bottles should happen to fall
98 bottles of beer on the wall
arrow_forward
7) The ideal gas law allows the calculation of volume of a gas given the pressure(P), amount ofthe gas (n), and the temperature (T). The equation is:V = nRT / PSince we only have used integer arithmetic, all numbers will be integer values with nodecimal points. The constant R is 8.314 and will be specified as (8314/1000). This givesthe same result. Implement the idea gas law program where the user is prompted for andenters values for n, T, and P, and V is calculated and printed out. Be careful toimplement an accurate version of this program. Your program should include a properand useful prompt for input, and print the results in a meaningful manner
arrow_forward
Exercise 4:
Write a program that reads two pieces of information: the hourly wages and the number of hours worked by the employee.
The program should then calculate the net salary of the employee and display the results as shown in Figure 4. Note that:
the net salary of the employee is the sum of the basic wages (which is number of hours worked times the hourly wages)
minus the Social Security fees; where the Social Security fees represent 10% of the Basic wages.
Name your program Lab3_Id_ex4.py, where Id is your university Id. Include the design of your solution as comments at
the beginning of your program. Test your solution with different input data.
Please enter the employee hourly wages?
10
please enter the number of hours worked?
40
Basic Salary
Hourly
Wages
Number of
Social
Net Salary
Hours
Security
****
10.000
40.00
400.000
40.000
360.000
****
Figure 4: Exercise 4 Sample Run
arrow_forward
1. Federal law requires that hourly employees be paid “time-and-a-half” for work in excess of 40 hours in a week.For example, if a person’s hourly wage is $12 and he or she works 60 hours in a week, the person’s gross pay shouldbe (40 *12) + (1.5 *12 * (60-40)) = $840.Write a program that requests the floating number of hours a person works in a given week and the person’s hourlywage as input, and then displays the person’s gross pay. Save it as overtimePay.py
arrow_forward
C Program
In order to discourage excess electric consumption, an electrical company charges its customers a lower rate of P75 for the first 250 kilowatt-hours and a higher rate of P8.5 for each additional kilowatt-hour. In addition, a 10% surtax is added to the final bill. Write a program that calculates the electrical bill given the number of kilowatt-hours consumed as input. At the end, print the number of kilowatt-hours consumed and the computed bill.
arrow_forward
Python
arrow_forward
2.13 LAB: Driving costs
Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 20
miles, 75 miles, and 500 miles.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3))
Ex: If the input is:
20.0
3.1599
Then the output is:
3.16 11.85 79.00
Note: Real per-mile cost would also include maintenance and depreciation.
318650.2047284.qx3zqy7
LAB
2.13.1: LAB: Driving costs
0/10
ACTIVITY
main.py
Load default template...
arrow_forward
need some help understanding how to write this please
arrow_forward
7. Write a function that evaluates the area of a pentagon. Use "math.pi", for
pi, and "math.sqrt" for square root. Write the solution on the space
provided below. You do not need to run the code.
311 3.2
(Geometry: area of a pentagon) Write a program that prompts the user to enter the
length from the center of a pentagon to a vertex and computes the area of the pen-
tagon, as shown in the following figure.
The formula for computing the area of a pentagon is Area
3√3
2
-s², where s is
TT
the length of a side. The side can be computed using the formula s = 2r sin
5'
where r is the length from the center of a pentagon to a vertex. Here is a sample
run:
Enter the length from the center to a vertex: 5.5 Enter
The area of the pentagon is 108.61
arrow_forward
1.27 LAB. Variables/Assignments: Driving costs
Drīving is expensive. Write a program with a car smiles gallon and gas dollars gallon (both floats) as input and output the gas cost for 10
miles, 50 miles, and 400 miles
Output the gas cost (gasCost) with two digits after the decima poin which can be achieved as follows
Put gasCost to output with 2 decimal places
Ex: If the inputis:
20.0 3.1599
the output is:
1.58 7.90 63.20
Note: Small expression differences can yield small floating-puintoulput di fferer ces aue to computerrounding Fx (a tb)/3.0is the same
as a/3.0 + b/3.0 but output may differ slightly. Because our system tesis programs hy comparing ouput please obey the following when
writing your expression for this problem. First use the dollars/gallon and miles/palon valucs to calculate the dollars/imile Then use the
dollars/mile value to determine the cost per 10, 50, and 400 miles.
Note: Real per-mile cost would also include maintenance and depreciation
387484.1009620 g3zny7
arrow_forward
***Microsoft Visual Studios (C++)***
Write a program that given two coordinate pairs and a third single coordinate will linearly interpolate or extrapolate the third second coordinate. For example, let's say at 50 degrees Celsius the length of a metal rod is 5.4 cm and at 60 degrees Celsius the length is 5.5cm. I can interpolate the length at 53 degrees Celsius by doing 5.4cm + 3*(.1/10)=5.43cm. Your program does not need to continuously run, but should prompt the user for two coordinate pairs, the third first coordinate and return the extrapolated or interpolated third second coordinate.
arrow_forward
2.23 LAB: Ordering pizza
A local pizza shop is selling a large pizza for $9.99. Given the number of pizzas to order as input, output the subtotal for the pizzas, and
then output the total after applying a sales tax of 6%.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print(f'Subtotal: ${yourValue:.2f}')
Ex: If the input is:
3
the output is:
Subtotal: $29.97
Total due: $31.77
382390.2469802.qx3zqy7
LAB
2.23.1: LAB: Ordering pizza
4/10
ACTIVITY
main.py
Load default template.
1
Type your code here. ''"
2
arrow_forward
2.15 LAB: Musical note frequencies
On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * rn, where n is the distance (number of keys) from that key, and r is 2(1/12). Given an initial key frequency, output that frequency and the next 4 higher key frequencies.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print(f'{your_value1:.2f} {your_value2:.2f} {your_value3:.2f} {your_value4:.2f} {your_value5:.2f}')
arrow_forward
10) Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D,
and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or
F-. The symbol + increases the numeric value by 0.3, and the symbol - decreases it by 0.3. For
example:
Enter a letter grade: B-
The numeric value of B- is 2.7.
arrow_forward
use a while loop to solve this problem. This is a Java program
arrow_forward
6) Write a program to guess a number chosen by the user. In this program a user will choose asecret number from 1..maximum. The program will prompt the user for the maximum value,which the user will enter. The program will then make a guess as to the value of the secretnumber, and prompt the user to say if the actual number is higher, lower, or correct. Thecomputer will then guess another number until it guesses the correct secret number.
arrow_forward
Alert -Don't submit AI generated answer and i need unique response only if I see plagiarism then I'll reduce rating for sure.
arrow_forward
This is for c++.
arrow_forward
2. C program to draw pyramid with *.
Ex – height 4:
***
*****
*******
Hint: According to bottom line, find the number of blank characters at the first line(how many
blank is at right side and how many blank is at left side?). If height of pyramid is 4, then
bottom line has got 7 asterix ((4-1)*2+1). First line has got 6 blank (4-1 left side and 4-1 right
side) characters and one Asterix (at the middle.
arrow_forward
Page 104 - #9
Write a program that takes the length and width of a rectangular yard and the length and width
a rectangular house situated in the yard. Your program should compute the time required to cut
the grass at the rate of two square foot a second.
arrow_forward
Implement the following two functions:
// Returns true if all the sides of the triangle // are same.
bool isValid(double side1, double side2, double side3)
// Returns the perimeter of an equilateral triangle.double perimeter(double side1)
The formula for computing the perimeter is perimeter = 3 * side. Write a test program that reads three sides for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid.
arrow_forward
6.14 Lab: Reversing an Integer.
In this problem, your task is to complete the reverseNumber(num) function. The input of the function is an integer number num. The function should return a number where all the digits are reversed from the original number.
You can assume that the input will be a non-negative integer.
Example 1: If the input is:
123
The output is:
321
Example 2: If the input is:
321
The output is:
123
Example 3: If the input is:
1000
The output is:
1
Brainstorming. Oftentimes, a problem as formulated can be made easier when you change the way the data is represented. In this case, this problem can be solved in a clever way using strings. If you first convert the number into a string, you can then reverse the string and convert the number back to an integer.
def reverseNumberUsingString(num): numInStringFormat = str(num) #converts the number into a string reversedNumberInStringFormat = numInStringFormat[::-1] #reverses the string reversedNumber =…
arrow_forward
4.7: Time Machine Your time machine is capable of going forward in time up to 24 hours. The machine is configured to jump ahead in minutes. To enter the proper number of minutes into your machine, you would like a program that can take a start time (in hours, minutes, and a Boolean indicating AM or PM) and a future time (in hours, minutes, and a Boolean indicating AM or PM) and calculate the difference in minutes between the start and future time.
A time is specified in your program with three variables:
int hours, minutes;
bool isAM; // You can also use a char, i.e. A or P
Write a program that allows the user to enter a start time and a future time. Include a function named computeDifference that takes the six variables as parameters that represent the start time and future time. Your function should return, as an int, the time difference in minutes. for example, given a start time of 11:59 AM and a future time of 12:01 PM, your program should compute 2 minutes as the time difference.…
arrow_forward
4.7: Time Machine Your time machine is capable of going forward in time up to 24 hours. The machine is configured to jump ahead in minutes. To enter the proper number of minutes into your machine, you would like a program that can take a start time (in hours, minutes, and a Boolean indicating AM or PM) and a future time (in hours, minutes, and a Boolean indicating AM or PM) and calculate the difference in minutes between the start and future time.A time is specified in your program with three variables:int hours, minutes;bool isAM;for example, to represent 11:50 PM, you would store:hours = 11,minutes = 50,isAM = false
This means that you need six variables to store a start and future time.
Write a program that allows the user to enter a start time and a future time. Include a function named computeDifference that takes the six variables as parameters that represent the start time and future time. Your function should return, as an int, the time difference in minutes. for example,…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Related Questions
- Python all info is therearrow_forward3.12 LAB: Seasons Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day. Ex: If the input is: April 11 the output is: Spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is: Blue 65 the output is: Invalid The dates for each season are:Spring: March 20 - June 20Summer: June 21 - September 21Autumn: September 22 - December 20Winter: December 21 - March 19 247772.2002516.qx3zqy7arrow_forward3.4 LAB: Seasons Write a program that takes a date as input and outputs the date's season in the northern hemisphere. The input is a string to represent th month and an int to represent the day. Note: End with a newline. Ex: If the input is: April 11 the output is: Spring In addition, check if the string and int are valid (an actual month and day) Ex. If the input is Blue 65 the output is Invalid. The dates for each season in the northern hemisphere are: Spring: March 20-June 20 Summer June 21-September 21 Autumn September 22- December 20 Winter December 21- March 19arrow_forward
- PP 6.4 Write a program that prints the first few verses of the traveling song “One Hundred Bottles of Beer." Use a loop such that each iteration prints one verse. Read the number of verses to print from the user. Validate the input. The following are the first two verses of the song: 100 bottles of beer on the wall 100 bottles of beer If one of those bottles should happen to fall 99 bottles of beer on the wall 99 bottles of beer on the wall 99 bottles of beer If one of those bottles should happen to fall 98 bottles of beer on the wallarrow_forward7) The ideal gas law allows the calculation of volume of a gas given the pressure(P), amount ofthe gas (n), and the temperature (T). The equation is:V = nRT / PSince we only have used integer arithmetic, all numbers will be integer values with nodecimal points. The constant R is 8.314 and will be specified as (8314/1000). This givesthe same result. Implement the idea gas law program where the user is prompted for andenters values for n, T, and P, and V is calculated and printed out. Be careful toimplement an accurate version of this program. Your program should include a properand useful prompt for input, and print the results in a meaningful mannerarrow_forwardExercise 4: Write a program that reads two pieces of information: the hourly wages and the number of hours worked by the employee. The program should then calculate the net salary of the employee and display the results as shown in Figure 4. Note that: the net salary of the employee is the sum of the basic wages (which is number of hours worked times the hourly wages) minus the Social Security fees; where the Social Security fees represent 10% of the Basic wages. Name your program Lab3_Id_ex4.py, where Id is your university Id. Include the design of your solution as comments at the beginning of your program. Test your solution with different input data. Please enter the employee hourly wages? 10 please enter the number of hours worked? 40 Basic Salary Hourly Wages Number of Social Net Salary Hours Security **** 10.000 40.00 400.000 40.000 360.000 **** Figure 4: Exercise 4 Sample Runarrow_forward
- 1. Federal law requires that hourly employees be paid “time-and-a-half” for work in excess of 40 hours in a week.For example, if a person’s hourly wage is $12 and he or she works 60 hours in a week, the person’s gross pay shouldbe (40 *12) + (1.5 *12 * (60-40)) = $840.Write a program that requests the floating number of hours a person works in a given week and the person’s hourlywage as input, and then displays the person’s gross pay. Save it as overtimePay.pyarrow_forwardC Program In order to discourage excess electric consumption, an electrical company charges its customers a lower rate of P75 for the first 250 kilowatt-hours and a higher rate of P8.5 for each additional kilowatt-hour. In addition, a 10% surtax is added to the final bill. Write a program that calculates the electrical bill given the number of kilowatt-hours consumed as input. At the end, print the number of kilowatt-hours consumed and the computed bill.arrow_forwardPythonarrow_forward
- 2.13 LAB: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3)) Ex: If the input is: 20.0 3.1599 Then the output is: 3.16 11.85 79.00 Note: Real per-mile cost would also include maintenance and depreciation. 318650.2047284.qx3zqy7 LAB 2.13.1: LAB: Driving costs 0/10 ACTIVITY main.py Load default template...arrow_forwardneed some help understanding how to write this pleasearrow_forward7. Write a function that evaluates the area of a pentagon. Use "math.pi", for pi, and "math.sqrt" for square root. Write the solution on the space provided below. You do not need to run the code. 311 3.2 (Geometry: area of a pentagon) Write a program that prompts the user to enter the length from the center of a pentagon to a vertex and computes the area of the pen- tagon, as shown in the following figure. The formula for computing the area of a pentagon is Area 3√3 2 -s², where s is TT the length of a side. The side can be computed using the formula s = 2r sin 5' where r is the length from the center of a pentagon to a vertex. Here is a sample run: Enter the length from the center to a vertex: 5.5 Enter The area of the pentagon is 108.61arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning