Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:06:30+00:00 2026-06-12T12:06:30+00:00

So I am supposed to make a vending machine for my intro to programming

  • 0

So I am supposed to make a vending machine for my intro to programming class Lab. So far this is what my Java code looks like.

import java.util.Scanner;
public class VendingMachine
{
       public static void main (String[] args)
    {
 Scanner keyboard = new Scanner(System.in);

final int quarter = 25;
final int dime = 10;
final int nickel = 15;
int cost = keyboard.nextInt ();

int totalChange = 100 - cost;
int totalQuarters= totalChange/quarter;
totalChange = totalChange % quarter;
int totalDimes = totalChange/dime;
totalChange = totalChange % dime;
int totalNickels = totalChange/nickel;
totalChange = totalChange % nickel;

System.out.print("Enter Price for your item" + "30" );

 }
}

What I need it to do is this.

Enter a price for item (from 25 cents to a dollar, in 5-cent increments): 45


You bought and item for 45 cents and gave me a dollar, so your change is

 2 quarters,

 0 dimes, and

 1 nickels.

With the values 30 , 65, and 100. For some reason the program will not start up in Blue J..so I know Eclipse is recommended but I think I want to finish this lab with Blue J, anyone have any tips?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:06:31+00:00Added an answer on June 12, 2026 at 12:06 pm

    My guess is that the program is starting, but you don’t realize it because it is waiting for input.

    Move the line containing System.out.print("Enter Price for your item" + "30" ); above your keyboard.nextInt scanning for input. Like so:

    System.out.print("Enter Price for your item" + "30" );
    int cost = keyboard.nextInt ();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had trouble writing this code. I'm supposed to make a function that can
With this code I am supposed to make flashes with the key success different
For my software development programming class we were supposed to make a Feed Manager
I'm supposed to make my own Java Triangle class for my project at school.
A very strange situation, I've got this code that is supposed to make an
This code is supposed to make a slideshow out of stacked list-elements (I commented
I supposed to make this type of charts, is it posssible to make through
So I am supposed to make 3 classes and am given a 4th class
The following code is supposed to make the right 60% of the display red.
I am supposed to make a class that should be a container for an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.