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
skelet666 [1.2K]
4 years ago
6

Write a program (Console or GUI) that determines the change to be dispensed from a vending machine. An item in the machine can c

ost between 25 cents and 1 dollar, in 5-cent increments (25, 30, 35,…,95, 100), and the machine accepts only a single dollar bill to pay for the item. For example, a possible sample dialog might be the following:
Output: Enter price of item (from 25 cents to a dollar, in 5-cent increments):

45 You bought an item for 45 cents and gave me a dollar, so your change is 2 quarters, 0 dimes, and

Computers and Technology
1 answer:
Stells [14]4 years ago
3 0

Answer:

Here is the JAVA program:

import java.util.Scanner;  //to accept input from user

public class Main {   //class name

  public static void main(String[] args) {  //start of main function

Scanner input =new Scanner(System.in);  // creates Scanner class object

int amount, quarters, dimes, nickels, pennies,change;   //declare variables

System.out.println("Enter the price of the(from 25 cents to a dollar, in 5-cent increments): ");  //prompts user to enter the price

amount=input.nextInt();   //reads amount from user

change= 100-amount;   //computes change

System.out.println("You bought an item for " + amount+" cents and gave me a dollar, so your change is :");  

quarters=change/25;  //computes quarters

change=change%25;  //computes quarter remaining

if(quarters == 1)   // if quarter is equal to 1

System.out.println(quarters+ " quarter");   //prints quarter value in singular

else if (quarters>1)   // if value of quarters is greater than 1

System.out.println(quarters+" quarters");     //prints plural quarters value

dimes=change/10;  //computes dimes

if(dimes == 1)   // if value of dime is equal to 1

System.out.println(dimes+ " dime");   //prints single value of dimes

else if (dimes>1)   //if value of dimes is greater than 1

System.out.println(dimes+" dimes");  //prints plural value of dimes

change=change%10;   //computes dimes remaining

nickels=change/5;  //computes nickels

if(nickels == 1)   //if value of nickels is equal to 1

System.out.println(nickels+ " nickel");   //prints single value of nickels

else if (nickels>1)   //if value of nickels is greater than 1

System.out.println(nickels+" nickels");   //prints plural value of nickels

change=change%5;    //computes nickels remaining

pennies=change;  //computes pennies

if(pennies == 1)   //if value of pennies is equal to 1

System.out.println(pennies+ " penny");   //prints single value of pennies

else if (pennies>1)    //if value of pennies is greater than 1

System.out.println(pennies+" pennies");     } }  //prints plural value of pennies

Explanation:

I will explain the program with an example:  

Suppose amount= 75  

Then change = 100 - amount= 100 - 75 = 25  

change = 25  

quarters = change/25 = 25/25 = 1  

quarters = 1  

change = change % 25 = 25%25 = 0  

dimes = 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 quarters == 1  

This is true because value of quarter is 1  

sot "quarter"   is displayed with the value of quarters

Now the following line is printed on screen:  

1 quarter  

So the complete output of the program is:  

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

1 quarter

You might be interested in
I have been trying to use brainly recently but i cant because everytime i watch an ad to get an answer, its an interactive ad, s
Troyanec [42]

Answer:

remove ads

Explanation:

by buying a no ad pack

5 0
2 years ago
Is the wireless network you own as secure as it should be? Examine your wireless network or that of a friend or neighbor and det
AleksandrR [38]

Answer:

See explaination

Explanation:

Wireless Security:

In a bid to examine the network you can use ipconfig /all command in windows or in the event where you are a linux user type in ifconfig to view all the configuration details of your network such as

indows IP Configuration

Host Name . . . . . . . . . . . . : myvpc-hb

Primary Dns Suffix . . . . . . . : example.com

Node Type . . . . . . . . . . . . : Hybrid

IP Routing Enabled. . . . . . . : Yes

Ethernet adapter Local Area Connection:- - - - - -

Connection-specific DNS Suffix . :- - - - - -

Description . . . . . . . . . . : Intel 68540-Based PCI Express Fast Ethernet Adapter

Physical Address. . . . . . . . . : 00-03-AA-BC-CA-8F

Autoconfiguration Enabled . . . . : Yes

Link-local IPv6 Address . . . . . : fe65::ab56:ccb9:320c:524d%8(Preferred)

IPv4 Address. . . . . . . . . . . : 192.168.45.111(Preferred)

Default Gateway . . . . . . . . . : 192.168.15.1

DHCP Server . . . . . . . . . . . : 192.168.15.1

DHCPv6 IAID . . . . . . . . . . . : 201327615

Note: If you want to deeply examine the your network and to find security model go with Wireshark application.It will help you to capture the data packets easily using GUI.Also it will provide other details like transmission control protocols,etc.

To take your network to highest level i.e. to make it more secure you can use:

1.Firewalls like application gateways,packet filtering,hybrid systems.

2.Crypto cable routers

3.Virtual private networks, etc.

Estimation of cost and the time to increase the level is solely depends on the type of the architecture you want to use for the network building structure.Also the size of the network will be responsible for the cost and time.

In case of any attack on your computer it depends on the size of the data on the computer disc and the bandwidth of the network to which your computer is connected to replace all data. The faster the bandwidth of the network,faster the data replacement rate.

3 0
3 years ago
If there is an value in a array, and the same value comes at the same spot, does it cancel each other out or does it reassing th
kondaur [170]

Explanation:

In simple English, an array is a collection.

In C also, it is a collection of similar type of data which can be either of int, float, double, char (String), etc. All the data types must be same. For example, we can't have an array in which some of the data are integer and some are float.

8 0
3 years ago
IMPORTANT HELP
balu736 [363]

Answer:

plz am so sorry I don't no it

Explanation:

Plz give me brainiest

6 0
3 years ago
____ gets its name from the notion that it ignores the traditional A, B, and C class designations for IP addresses and can there
Sedbober [7]

<u>Classless Inter-Domain Routing</u> gets its name from the notion that it ignores the traditional A, B, and C class designations for IP addresses and can therefore set the network-host ID boundary wherever it wants to, in a way that simplifies routing across the resulting IP address spaces.

<u>Explanation</u>:

A router is a networking device that helps in connecting multiple networks. <em><u>Classless Inter-Domain Routing (CIDR) </u></em>is used for creating IP addresses and IP routing. CIDR was introduced in the year 1993 by <em><u>“The Internet Engineering Task Force”</u></em>. The classful network design was replaced by CIDR in the Internet.

The IP addresses are responsible for sending the particular information packets to specific computers. Classless inter-domain routing helps in improving the allocation of IP addresses.

7 0
4 years ago
Read 2 more answers
Other questions:
  • Alex leads a team of eight members. Arrange his tasks in sequential order of phases of group dynamics. What are the stages in gr
    13·1 answer
  • Design an algorithm for finding all the factors of a positive integer. For example, in the case of the integer 12, your algorith
    8·1 answer
  • The systems development life cycle (SDLC) is the overall process of developing, implementing, and retiring information systems t
    9·1 answer
  • 1. cybersquatting refers to the tampering of existing web sites and selling unrelated products (true or false)
    8·1 answer
  • What kind of company would hire an Information Support and Service employee?
    7·1 answer
  • If your computer has a ________, someone else can gain access to it undetected.
    10·1 answer
  • HELP!!! Bad things about Helen Keller. I'm doing a debate and i need to prove that Steve Jobs is better than Helen Keller!!
    14·1 answer
  • How is an interpreter different from a compiler?
    9·2 answers
  • 7. Accepting things that happen without trying to change them is known as
    6·1 answer
  • Basics of visual basic
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!