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
statuscvo [17]
3 years ago
11

Write a program that simulates the functionality of a vending machine having the following characteristics:• The vending machine

offers 5 products• The vending machine accepts coins, 1 dollar bills, and 5 dollar bills• The change is always given in coins, with maximum possible number of coins in each value: 25, 10, 5 or 1 cent.• The selections available for user are numbers from 1 to 5.• The user enters the money – simulate the action through a loop that ends when the user enters 0. Each coin, or paper bill will be read individually.• The user makes the selection, and the machine allows a maximum 4 other selections if the amount entered doesn’t cover the price of the item.• Once an item is delivered, the machine gives the change in coins.• There is no increment for the money during one selection.• The user can stop the selection at any time by entering 0 for the product selection.• If the user chooses to cancel the selection, the machine returns the initial amount in coins.• Display the outcome of the operation for each alternative you consider possible for the vending machine.• Make sure that the machine returns the correct change at all times.
Computers and Technology
1 answer:
ValentinkaMS [17]3 years ago
5 0

Answer:

Check the explanation

Explanation:

import java.util.*;

public class VendingMachineAssignement {

   public static void main(String[] args) {

       Scanner keyboard = new Scanner(System.in);

       double item1 = 1.25;

       double item2 = .75;

       double item3 = .90;

       double item4 = .75;

       double item5 = 1.50;

       double item6 = .75;

       System.out.print("Enter an item number: ");

       int item = keyboard.nextInt();

       System.out.print("Enter the amount paid: ");

       double paid = keyboard.nextDouble();

       if (item == 2 || item == 4 || item == 6)

       {

           if (paid >= item2)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item2) + ". Please come again!");

           }

           if (paid < item2)

           {

               System.out.println("Please insert another " + "$" + (item2-paid));

           }

       }

       else if (item == 1)

       {

           if (paid >= item1)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item1) + ". Please come again!");

           }

           if (paid < item1)

           {

               System.out.println("Please insert another " + "$" + (item1-paid));

           }

       }

       else if (item == 3)

       {

           if (paid >= item3)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item3) + ". Please come again!");

           }

           if (paid < item3)

           {

               System.out.println("Please insert another " + "$" + (item3-paid));

           }

       }

       else if (item == 5)

       {

           if (paid >= item5)

           {

               System.out.println("Thank you for buying item " + item + ", your change is $" + (paid-item5) + ". Please come again!");

           }

           if (paid < item5)

           {

               System.out.println("Please insert another " + "$" + (item5-paid));

           }

       }

   }

}

You might be interested in
Write a C++ program to count even and odd numbers in array. The array size is 50. The array elements will be entered by the user
vlabodo [156]

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

int main(){

   int numbers[50];

   int evekount = 0, odkount = 0;

   for(int i = 0; i<50;i++){

       cin>>numbers[i];

       if(numbers[i]%2==0){            evekount++;        }

       else{            odkount++;        }

   }

   cout<<"Even Count: "<<evekount<<endl;

   cout<<"Odd Count: "<<odkount<<endl;

   return 0;

}

Explanation:

This declares the integer array of number

   int numbers[50];

This initializes the even count and odd count to 0

   int evekount = 0, odkount = 0;

This iterates from 1 to 50

   for(int i = 0; i<50;i++){

This gets input for the array

       cin>>numbers[i];

This checks for even

<em>        if(numbers[i]%2==0){            evekount++;        }</em>

This checks for odd

<em>        else{            odkount++;        }</em>

   }

This prints the even count

   cout<<"Even Count: "<<evekount<<endl;

This prints the odd count

   cout<<"Odd Count: "<<odkount<<endl;

3 0
3 years ago
write code that removes the first and last elements from a list stored in a variable named my_list. assume that the list has bee
MakcuM [25]

Answer:

[24, 35, 9, 56 Approach #3: Swap the first and last element is using tuple variable.

8 0
3 years ago
Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
katovenus [111]

Answer:

He can use following computer program to make the class room more interesting and effective:-

  • 1. <u>Reference software</u> : This software help students to access the atlases and dictionaries.Teacher can include this software in research projects .

  • 2. <u>Educational Games</u>: This types of software is very effective for younger children because it motivates them to learn.This software companies have combined gaming and education into one .

  • 3. <u>Graphical software</u> : Student can use this software to create and changes images available on the internet itselfs .
4 0
3 years ago
Read 2 more answers
Intel Centrino Technology is the combinatin of wirelesstechnology with the previous HT technology.
Kay [80]

Answer:

<u>False</u>

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

The Intel Centrino Technology is a product marketed and sold by the tech giant Intel, which offers a combination of their Wi-Fi and WiMax technologies in a single personal laptop. It does not offer Hyper threading Technology (HT) like some of the other Intel branded CPU's. Some of the CPU's that include hyper threading are the Core I3 series.

Therefore, based on the information stated above, we can see that the statement in the question in <u>False</u>.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
3 years ago
Rest or take a break every __ minutes when typing. Please help!
Talja [164]
Maybe like 3-5 I think im right
3 0
4 years ago
Read 2 more answers
Other questions:
  • I only want someones opinion on this not anything you would find in a book.
    7·1 answer
  • Describe an application where a parallel circuit might work better than a series circuit.
    15·1 answer
  • Implement a program to measure the impact of application-level buffer sizes on read time. This involves writing to and reading f
    13·1 answer
  • The main parts of a lever are the....
    6·2 answers
  • Which of the following people was a member of FFA?
    7·1 answer
  • One key to success in a career is to be an accomplished
    15·1 answer
  • You are troubleshooting a client connectivity problem on an Ethernet network. The client system has intermittent connectivity to
    9·1 answer
  • In what ways can you modify the location of the neutral point?
    11·1 answer
  • Tips for staying safe using social media. Using in your own words.
    6·1 answer
  • GIVING BRAINLIEST
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!