Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


CS 112  Spring 2022  Programming Assignment 1

Basic Expressions and Statements


The purpose of this assignment is to practice using basic expressions and statements effectively, as well as getting input from the user and displaying results onto your terminal window.

See the Assignment Basics file for more detailed information about getting assistance, running the test file, grading, commenting, and many other extremely important things. Each assignment is governed by the rules in that document. Assignment Basics can be found under the “Read Programming Assignment Instructions here” link in Blackboard.

Needed Files: download these attached files to use the tests we will use when grading your work.

• tester1.py

• tests.txt

Background:

Programs  are  more  interesting  when  they  involve  the  user  –  supplying  values  to  use  in calculations, asking for names, and so on. We can get a string from the user via the input() function, and then convert to other types as needed via other built-in functions of Python, such as int()float(), and bool().

Variables give us the chance to store values for later, recallable by name. We can even repeatedly update the value associated with that name, as a replacement: forgetting the old value forever, remembering the new value until  further notice. As procedural programs  are very much  a sequence of executed instructions, the exact order of when we store (or replace) a value for a variable, and when we look up and use the current value, is an important part of understanding how to create the solution to a programming task.

This assignment will get us comfortable getting values ofvarious types from the user and using variables while calculating different things. The next assignments will explore control structures like branching and loops, so be sure to master these more basic tasks first.


Task:

Sage owns a business that makes specialty cakes for weddings. Their company creates three   types of cakes. Sage approached you to help create an application for them to manage pricing for their cake orders. Here are the specifications regarding their cakes:

A 2-tier cake can feed 30 people.

A 2-tier specialty Cake A takes Sage’s baker 15 hours to complete, and Sage also pays their cake consultant 1 hour of pay for working with the soon to be wedded couple.

A 2-tier specialty Cake B takes Sage’s baker 14 hours to complete, and Sage pays their cake consultant 2 hours of pay.

A 2-tier specialty Cake C takes Sage’s baker 16 hours to complete, and Sage pays their cake consultant 1.5 hours of pay.

Sage’s Baker’s hourly wage is $15.

Sage’s Consultant’s hourly wage is $12.50.

 

A 2-tier specialty Cake A costs Sage about $35 in ingredients, frosting, fondant, etc. A 2-tier specialty Cake B costs Sage about $30 in ingredients, frosting, fondant, etc. A 2-tier specialty Cake C costs Sage about $40 in ingredients, frosting, fondant, etc.

pricing allows for them to make a 10% profit per cake.

 

Procedure:

Create your python file, following the instructions from the Assignment Basics file. Perform the following actions in your code, storing their answers as needed in variables.

1.  Greet the user with the message, "Sage’s Wedding Cake Price Calculator"

2.  Ask the user: "Total People Attending: "

3.  Compute and output the labor cost to make Cake A

4.  Compute and output the total cost to make Cake A

5.  Compute and output the total to charge the customer for Cake A

6.  Compute and output the labor cost to make Cake B

7.  Compute and output the total cost to make Cake B

8.  Compute and output the total to charge the customer for Cake B

9.  Compute and output the labor cost to make Cake C

10.Compute and output the total cost to make Cake C

11.Compute and output the total to charge the customer for Cake C


Example Code Runs:

value in the red box is the user input, the rest is calculated output. 

 

Hint to Pass the Tester: Even ifyour math and your math output is correct, your program must have the exact spelling and upper/lower case letters as well as the exact same number ofdashes and spaces and tabsfor your code to pass the tester. So, here are some tips. There are exactly 40 dashes in the dashes output between Cake A, B and C. There are 5 spaces after the words Labor

Cost:, there are 3 spaces after the words Cost to Make: and there is 1 space after the words Charge Customer; a specific escape sequence was usedfor thefurther spacing. The output values were rounded to 2 spaces after the decimal.


Assumptions:

In computer science, exact formatting of input/output is like putting on socks with shoes, while people might not do it 100% of the time in their personal life, it is extremely unusual not to do it in a professional setting. Therefore, you will need to format your input/output exactly like the samples provided. As we are just starting to program, and don't even have if-else statements at our disposal, we will assume many things to make the project easier, though it makes the project slightly more artificial.

You may assume thefollowing:

• The user will always enter the correct data type asked for

• Every number the user enters will be a positive real number when testing this project

Restrictions:

Allowed Things:

•   All arithmetic operators: +-*/%//, **, =

•   The following data types and their casting functions: intfloatstring

•   Any Escape Sequence

•   These functions: input()print(), round()

 

Disallowed Things:

•   You may not import other modules (like math) or write your own modules

•   You may not use string formatting operations and related functionality

•   You may not create your own functions (do it the long way)

•   No branching (if statements), or loops (for/while), or any other feature we haven’t yet covered in class

•   Do not pre-calculate prices on paper and then use the calculated price value in code. Do all the calculations in code.


Testing Your Code:

The tester for this assignment expects exact matching to pass a test case. If you're getting the right numbers but failing test cases, check for spacing issues, capitalization, spelling errors, and so on – look closely, and you can figure it out! You get to see the exact tests we'll use when we grade your code, so you might as well get them all correct before turning in your work! No surprises there.

One note, the OUTPUT section of the tests only includes what the program is supposed to print and does not include the characters that a user would be typing during the interaction (including when the user hits enter for a newline). This makes the output look a bit weird, but the testing file is correct.

To test your code with the provided tester, first make sure that you have downloaded the files "tester1.py"  and  "tests.txt"  into the  same  folder  as your  assignment  code. Then,  from that directory, run the following command using your command-line interface:

python3 tester1.py gmason_299_PA1.py

................

 

++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++

 

passed 8/8 tests.

 

Instead of python3, use py or python on the Windows machine.

If you pass all the tests, you will see the above contents. If you don't pass a test, you will be informed of where the mismatch in your output is, and you can figure out from there what needs to be fixed.


----------------------------------------------------------------------------------------------------------------- Submitting Your Code:

 

Submit your .py file to Gradescope under Programming Assignment 1

• link to Gradescope is in our Blackboard page under the link “Programming Assignments submit to Gradescope here”

• Don’t forget to name your file netID_2xx_PA1.py, where netID is NOT your G-number but your GMU email ID and 2xx is your lab section number.

• Don’t forget to copy and paste the honor code statement from the Assignments Basics document to the beginning of your submission .py file.

• Don’t forget to comment your code

• No hard coding!

 

Grading Rubric:

Correct Submission (file is named correctly):   5

 

Well-Documented (code is commented):

5

Calculations Correct:

40

------------------------------------

 

TOTAL:                                  50

 

 

Note:  If your code does not run (immediately crashes due to errors), it will receive at most 12 points. No exceptions. As stated on our syllabus, turning in running code is essential.