Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exam 2 Convert Dollars to Cookies: Programming You are supposed to write a program that asks the user to enter in a dollar amount (such

image text in transcribed

Exam 2 Convert Dollars to Cookies: Programming You are supposed to write a program that asks the user to enter in a dollar amount (such as 60.75). You will then tell the user how many cookies they can buy with that money In our program, one cookie costs 1.25s For example, ifthe user enters in 4.50, they can buy 3 cookies. should loop and keep asking for the dollar amount and printing out the number of cookies until the user enters -1. If the user enters in -1, you stop asking and the program ends. However, you should define and use SENTINEL for-1, similar to what you have done for our programming homework assignments You need to write a function that returns the number of cookies you can buy for a certain amount. The method will take in as a parameter the dollar amount. Choose a reasonable parameter name and a reasonable function name. Each time the user enters in the dollar amount, you will call the function you wrote and then print out both the dollar amount entered and the number of cookies. Format the output so you p rint out two numbers after the decimal and make sure the numbers are lined up neatly underneath their corresponding titles. money cookies 30.50 24 Copy and paste your output from a successful run into a comment at the bottom of the file. Make sure you put a comment of your name somewhere. Other than that, you don't need to worry about comments for this program Upload your program to Blackboard once you are done. Exam 2 Convert Dollars to Cookies: Programming You are supposed to write a program that asks the user to enter in a dollar amount (such as 60.75). You will then tell the user how many cookies they can buy with that money In our program, one cookie costs 1.25s For example, ifthe user enters in 4.50, they can buy 3 cookies. should loop and keep asking for the dollar amount and printing out the number of cookies until the user enters -1. If the user enters in -1, you stop asking and the program ends. However, you should define and use SENTINEL for-1, similar to what you have done for our programming homework assignments You need to write a function that returns the number of cookies you can buy for a certain amount. The method will take in as a parameter the dollar amount. Choose a reasonable parameter name and a reasonable function name. Each time the user enters in the dollar amount, you will call the function you wrote and then print out both the dollar amount entered and the number of cookies. Format the output so you p rint out two numbers after the decimal and make sure the numbers are lined up neatly underneath their corresponding titles. money cookies 30.50 24 Copy and paste your output from a successful run into a comment at the bottom of the file. Make sure you put a comment of your name somewhere. Other than that, you don't need to worry about comments for this program Upload your program to Blackboard once you are done

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions