answer.
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
Vika
15 days 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:
Amiraneli [1K]15 days ago
6 0

Answer:

input price

set change to one 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 acquired an item for price cents and paid 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:

A clearer way to express the pseudocode above could involve using alternative names for change as:

input price

set change to one 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 purchased an item for" price"cents and provided 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"

Next, I will illustrate the pseudocode through an example:

Let's assume price = 75

Thus, 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

At this point, all additional values are 0.

The following message will be displayed on the screen:

You acquired an item for 75 cents and paid me a dollar. Your change is:

Now the program proceeds to the conditional statement

if quarter == 1

This condition holds true because the value of quarter is 1

print quarter "quarter"

Subsequently, this line will appear on the screen:

1 quarter

Thus, the full output of the pseudocode is:

You acquired an item for 75 cents and paid me a dollar. Your change is:

1 quarter

You might be interested in
On January 1, 1980, Moises deposited $1850 into a savings account paying 5.6% interest, compounded quarterly. If he hasn't made
Natasha_Volkova [1026]
According to the rule of 72, dividing 72 by the interest rate gives the time needed to double your investment. With an interest rate of 5.6%, we calculate 72/5.6 = 12.86 years. Thus, to increase the amount from $1850 to $3700, it would take approximately 12.86 years, suggesting that by late 1992 the balance would reach $3700.
8 0
14 days ago
Read 2 more answers
(Java) Which of the following code segments correctly declare a Strings and gives it a value of "fortran".
maria [1035]

Response:

IT F

Clarification:

8 0
1 month ago
Write an if-else statement to describe an integer. Print "Positive even number" if isEven and is Positive are both true. Print "
Harlamova29_29 [1022]

Answer:

Below is the explanation for the C code.

Explanation:

#include <stdio.h>

#include <stdbool.h>

int main(void) {

int userNum;

bool isPositive;

bool isEven;

scanf("%d", &userNum);

isPositive = (userNum > 0);

isEven = ((userNum % 2) == 0);

if(isPositive && isEven){

  printf("Positive even number");

}

else if(isPositive &&!isEven){

  printf("Positive number");

}

else{

  printf("Not a positive number");

}

printf("\n");

return 0;

}

6 0
1 month ago
To be a successful computer systems engineer, you must be proficient in programming languages and operating systems. Similarly,
maria [1035]

In summary, the skills listed are referred to as Technical capabilities. These capabilities encompass the Knowledge and skillset required to execute specific tasks. Meanwhile, Soft skills are equally vital, as they pertain to the capability of effectively engaging and communicating with others.

6 0
19 days ago
Read 2 more answers
if you had two proxy servers located in the same room, what use could you make of them? nothing create a hub sell one of the ser
Harlamova29_29 [1022]
Establish a free wifi service
6 0
1 month ago
Read 2 more answers
Other questions:
  • 6. Write pseudo code that will perform the following. a) Read in 5 separate numbers. b) Calculate the average of the five number
    6·1 answer
  • How to code 2.9.5: Four colored triangles {Code HS}
    10·1 answer
  • What are the 2 things you are not sure about evaluating functions​
    7·2 answers
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • Consider a load-balancing algorithm that ensures that each queue has approximately the same number of threads, independent of pr
    14·1 answer
  • Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
    7·1 answer
  • hard disk drive has 16 platters, 8192 cylinders, and 256 4KB sectors per track. The storage capacity of this disk drive is at mo
    13·1 answer
  • Define a public static method named f2s that takes a single String argument, the name of a file. The method returns a (concievab
    13·1 answer
  • Team A found 342 errors during the software engineering process prior to release. Team B found 184 errors. What additional measu
    12·1 answer
  • Write a program to read-in a sequence of integers from the keyboard using scanf(). Your program will determine (a) the largest i
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!