Problem 1. How Much Spaghetti Sauce? A spaghetti sauce recipe calls for the following ingredients: 2 cups of tomato sauce 1/3 cup of tomato paste (.333) 2 cloves garlic 1 tablespoon oregano The recipe produces 4 servings with this amount of ingredients. Write a program that asks the user how many servings they want to make, then displays the amount of each ingredient needed for the specified number of servings.,

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 28PE
icon
Related questions
Question
100%
Write in python for Problem 1.
Problem 1. How Much Spaghetti Sauce?
A spaghetti sauce recipe calls for the following ingredients:
2 cups of tomato sauce
1/3 cup of tomato paste (.333)
2 cloves garlic
1 tablespoon oregano
The recipe produces 4 servings with this amount of ingredients. Write a program that asks the user
how many servings they want to make, then displays the amount of each ingredient needed for the
specified number of servings.
Transcribed Image Text:Problem 1. How Much Spaghetti Sauce? A spaghetti sauce recipe calls for the following ingredients: 2 cups of tomato sauce 1/3 cup of tomato paste (.333) 2 cloves garlic 1 tablespoon oregano The recipe produces 4 servings with this amount of ingredients. Write a program that asks the user how many servings they want to make, then displays the amount of each ingredient needed for the specified number of servings.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I don't understand how my professor is asking us to code this? Reference picture

pseudocode steps that need to occur to produce the program's output. This includes formulas your
program will need. See sections 2.1 and 2.2 on designing a program and using pseudocode.
Code. Write your program in Python using the above steps. Save your program as a .py file with the
name yourlastname_Lab2.1.py
Output. Your program should produce correctly labeled output rounded to 2 decimal places. See
section 2.8 More About Output. Sample dialog:
Enter the number of servings of spaghetti sauce you want to make: 9
To make 9.0 servings of spaghetti sauce, you will need:
4.50 cups of tomato sauce
0.75 cups of tomato paste
4.50 cloves of garlic
2.25 tablespoons of oregano
Programming Style Requirements.
Comments - In-line comments are required for the code.
Variable names - use meaningful variable names such as total__taxes or num cookies.
Named constants - Use named constants for all number values that will not be changed in the
program such as RECIPE TOMATO_SAUCE = 2.0. See section 2.9 on Named Constants
H
Transcribed Image Text:pseudocode steps that need to occur to produce the program's output. This includes formulas your program will need. See sections 2.1 and 2.2 on designing a program and using pseudocode. Code. Write your program in Python using the above steps. Save your program as a .py file with the name yourlastname_Lab2.1.py Output. Your program should produce correctly labeled output rounded to 2 decimal places. See section 2.8 More About Output. Sample dialog: Enter the number of servings of spaghetti sauce you want to make: 9 To make 9.0 servings of spaghetti sauce, you will need: 4.50 cups of tomato sauce 0.75 cups of tomato paste 4.50 cloves of garlic 2.25 tablespoons of oregano Programming Style Requirements. Comments - In-line comments are required for the code. Variable names - use meaningful variable names such as total__taxes or num cookies. Named constants - Use named constants for all number values that will not be changed in the program such as RECIPE TOMATO_SAUCE = 2.0. See section 2.9 on Named Constants H
Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

What is another way to solve instead of %.2f?

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

I don't understand how the print convertion works to complete the recipe. Specifically the %2f.

×
12:09.
↑
Answered: Problem 1....
bartleby.com
SEARCH ASK CHAT VX MATH SOLV
Step 1:-
- The question is to code the spaghetti
problem in python.
Step 2: The executable code :-
n = int(input("The number of servings?
:"))
tomato_s = 0.5
values for 1 servings.
tomato_p= 0.083
garlic = 0.5
oregano = 0.25
✅0:
# Converting the
print("Used tomato sauce is %.2f"%
(n*tomato_s)) # printing the values with
proper formating
print("Used tomato paste is %.2f"%
(n*tomato_p))
print("Used garlic is %.2f"%(n*garlic))
print("Used oregano is %.2f"%
(n*oregano))
n = int(input("The number of servings? :"))
tomato_s = 0.5
tomato_p= 0.083
Step 3:- The code screenshot :-
garlic 0.5
oregano 0.25
80%
# Converting the values for 1 servings.
print("Used tomato sauce is %.2f"%(n*tomato_s))
print("Used tomato paste is %.2f"% (n tomato_p))
print("Used garlic is %.2f"% (n*garlic))
print("Used oregano is %.2f"%(n*oregano))
#printing the values with proper formating
Transcribed Image Text:× 12:09. ↑ Answered: Problem 1.... bartleby.com SEARCH ASK CHAT VX MATH SOLV Step 1:- - The question is to code the spaghetti problem in python. Step 2: The executable code :- n = int(input("The number of servings? :")) tomato_s = 0.5 values for 1 servings. tomato_p= 0.083 garlic = 0.5 oregano = 0.25 ✅0: # Converting the print("Used tomato sauce is %.2f"% (n*tomato_s)) # printing the values with proper formating print("Used tomato paste is %.2f"% (n*tomato_p)) print("Used garlic is %.2f"%(n*garlic)) print("Used oregano is %.2f"% (n*oregano)) n = int(input("The number of servings? :")) tomato_s = 0.5 tomato_p= 0.083 Step 3:- The code screenshot :- garlic 0.5 oregano 0.25 80% # Converting the values for 1 servings. print("Used tomato sauce is %.2f"%(n*tomato_s)) print("Used tomato paste is %.2f"% (n tomato_p)) print("Used garlic is %.2f"% (n*garlic)) print("Used oregano is %.2f"%(n*oregano)) #printing the values with proper formating
Solution
Bartleby Expert
SEE SOLUTION
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT