1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Liono4ka [1.6K]
3 years ago
9

Write the pseudocode that determines the change to be dispensed from a vending machine. An item in the machine can cost between

25 cents and a dollar, in 5-cent increments (25, 30, 35, .. . 90, 95, or 100), and the machine accepts only a single dollar bill to pay for the item. Requirements and example output. (bold items are user input,) . Only coins with a non-zero value should be displayed Item price must be 25 cents to a dollar, in 5-cent increments. Enter item price: 75 You bought an item for 75 cents and gave me a dollar. Your change is: 1 quarter If more than one coin is returned, the word should be plural with an "s" at the end Ifonly one coin is returned, the word should not have an "s" at the end. Item price must be 25 cents to a dollar, in 5-cent increments Enter item price: 35 You bought an item for 35 cents and gave me a dollar. Your change is: 2 quarters 1 dime 1 nickel
Computers and Technology
1 answer:
tatuchka [14]3 years ago
6 0

Answer:

input price

set change to hundred minus price

set quarter to change divided by 25

set change to change mod 25

set dime to change divided by 10

set change to change mod 10

set nickel to change divided by 5

set change to change mod 5

set penny to change

print "You bought an item for price cents and gave me a dollar. Your change is: "

if quarter is equal to 1

print quarter

else if quarter is greater than 1

print quarter with "quarters"

if dime is equal to 1

print dime

else if dime is greater than 1

print dime with "dimes"

if nickel is equal to 1

print nickel

else if nickel is greater than 1

print nickel with "nickels"

if penny is equal to 1

print penny

else if penny is greater than 1

print penny with "pennies"

Explanation:

One more understandable way of writing the above code is to use different names for change as:

input price

set change to hundred minus price

set quarter to change divided by 25

set quarter_remainder to change mod 25

set dime to quarter_remainder divided by 10

set dimes_remainder to quarter_remainder mod 10

set nickel to dimes_remainder divided by 5

set nickel_remainder to dimes_remainder mod 5

set penny to nickel_remainder

print "You bought an item for" price"cents and gave me a dollar. Your change is: "

if quarter is equal to 1

print quarter "quarter"

else if quarter is greater than 1

print quarter "quarters"

if dime is equal to 1

print dime "dime"

else if dime is greater than 1

print dime "dimes"

if nickel is equal to 1

print nickel "nickel"

else if nickel is greater than 1

print nickel "nickels"

if penny is equal to 1

print penny "penny"

else if penny is greater than 1

print penny "pennies"

I will explain the pseudocode with help of an example:

Suppose price = 75

Then change = 100 - price = 100 - 75 = 25

change = 25

quarter = change/25 = 25/25 = 1

quarter = 1

quarter_remainder = change % 25 = 25%25 = 0

dime = 0/10 = 0

Now all other values are 0.

Now the following line is printed on screen:

You bought an item for 75 cents and gave me a dollar. Your change is:

Now program moves to if part

if quarter == 1

This is true because value of quarter is 1

print quarter "quarter"

Now the following line is printed on screen:

1 quarter

So the complete output of the pseudocode is:

You bought an item for 75 cents and gave me a dollar. Your change is:

1 quarter

You might be interested in
Which of the following is normally mutually exclusive<br> Read only files<br> Printer<br> WIFI
marin [14]

Answer:

the answer is going to be printer

5 0
3 years ago
Saving a file as a new filename can be accomplished through the Save As dialog box? True<br> False
aliina [53]
Your answer would be true, (brainliest answer please)
7 0
3 years ago
What is the full form of ALU​
Alexandra [31]

Answer: arithmetic logic unit: the part of a central processing unit that performs arithmetic and logical operations.

Srry if it is wrong

I hope it  helps you

6 0
2 years ago
Read 2 more answers
To use Click and type feature can be used to format and enter text graphic and other items
trasher [3.6K]
No more info??? Because I can’t think of how to answer this
6 0
3 years ago
Which of the following does not accurately describe asynchronous communication?
worty [1.4K]

Answer:

A. While new media is dependent on whether users function in real-time or delayed mode, feedback is not as timely when communication is asynchronous.

Explanation:

Asynchronous communication can be defined as a data communication technique in which exchange of data between a sender and a recipient isn't in real time.

There's usually a time lag, meaning it doesn't require the recipient to respond immediately.

For example, responding to an email or text several hours later.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Identify the correct software or hardware applications in the passage below
    10·1 answer
  • The difference between the centerline of a vehicle and the line perpendicular to the rear wheels is called what?
    6·1 answer
  • The ________ contains the central electronic components of the computer. select one:
    14·1 answer
  • A powerful computer that acts as a hub for other computers is a called a ______.
    6·2 answers
  • Write a C++ program in which you declare variables that will hold an hourly wage, a number of hours worked, and a withholding pe
    12·1 answer
  • Instructions:Select the correct answer from each drop-down menu. What type of font color should Kim select if she chooses a dark
    10·2 answers
  • During which part of geologic time did photosynthesis evolve?
    15·2 answers
  • The random module is a group of functions that are used to deal with random numbers.
    10·2 answers
  • g How safe is to have a LinkedIn account where you have published all the important information about yourself
    13·2 answers
  • Please help with coding assignment.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!