Results 1 to 2 of 2
  1. #1
    jlcarrillo is offline Member
    Join Date
    Sep 2014
    Posts
    5
    Rep Power
    0

    Default Beginner Java Assignment Help (Calculations/Conversions)

    Here are the instructions to my assignment:

    A shopkeeper in Diagon Alley needs you to write a program that will calculate the
    correct amount of change due to a customer. (In Diagon Alley they use three coins with
    different values, given below).
    1. Prompt the user to input the amount of sale in Galleons, Sickles, and Knuts.
    2. Prompt the user to input the amount of money given by the customer in Galleons,
    Sickles, and Knuts.
    3. Create constants that represent:
    a. 1 Galleon = 17 Sickles
    b. 1 Sickle = 29 Knuts
    4. Perform the necessary calculations and conversions to compute the correct change
    in the least number of coins.
    5. create a formatted receipt recording the entire transaction.

    Here are what is steps 1 and 2 and 5 but i need help with are 3 and 4. I need to create the constants and use proper conversions to give the right amount of change back.

    Java Code:
    import java.util.Scanner;
     
    public class OperatorFormatting {
     
    	public static void main(String[] args) {
    		Scanner input = new Scanner(System.in);
    		System.out.println("Welcome to Flourish and Blotts");
     
    		System.out.print("Enter amount of sale (G S K): ");
    		int saleGalleon = input.nextInt();
    		int saleSickle = input.nextInt();
    		int saleKnut = input.nextInt();
     
    		System.out.print("Enter amount tendered (G S K): ");
    		int tendGalleon = input.nextInt();
    		int tendSickle = input.nextInt();
    		int tendKnut = input.nextInt();
     
    		System.out.println();
    		System.out.println("*************************************************");
    		System.out.println("*               Flourish & Blotts               *");
    		System.out.println("*                                               *");
    		System.out.println("*	Amt of Sale ....... " + saleGalleon + " G " + saleSickle + " S " + saleKnut + " K       *");
    		System.out.println("*	Amt Received ...... " + tendGalleon + " G  " + tendSickle + " S  " + tendKnut + " K       *");
    		System.out.println("*	Change Due ........ " + galleonChange + " G  " + sickleChange + " S  " + knutChange + " K       *");
    		System.out.println("*                                               *");
    		System.out.println("* Thank You For Shopping at Flourish and Blotts *");
    		System.out.println("*************************************************");
    	}
     
    }
    Basically, I need Help on steps 3 and 4 which are creating the constants and using the to make the proper conversions to give the customer the proper amount of change Due. Any help would be appreciated thank you.

  2. #2
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    393
    Rep Power
    9

    Default Re: Beginner Java Assignment Help (Calculations/Conversions)

    Hi jlcarrillo, welcome.

    Have a look a look at the section marked Constants in the following doc.
    Understanding Class Members (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Shout back if you require further assistance.

    Regards.

Similar Threads

  1. Java simple assignment help!! beginner
    By xemkruz2012 in forum New To Java
    Replies: 5
    Last Post: 02-03-2013, 01:08 AM
  2. Conversions
    By shahin912 in forum New To Java
    Replies: 7
    Last Post: 05-25-2012, 05:40 PM
  3. Beginner Java assignment
    By darstar007 in forum New To Java
    Replies: 6
    Last Post: 01-24-2012, 08:22 PM
  4. [SOLVED] Simple Calculations in Java
    By fullmetaljacket in forum New To Java
    Replies: 9
    Last Post: 05-19-2009, 03:19 AM
  5. Conversions
    By apfroggy0408 in forum New To Java
    Replies: 3
    Last Post: 03-04-2008, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •