Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How would I write this in Java?

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How would I write this in Java?

    Create a class named TestInvoice whose Main() method declares Three Invoice items. Create a method that prompts the user for and accepts values for the item number, name, quantity, and price for each Invoice. Then Display each completed object. Save the application as TestInvoice.java


    Code for Invoice:
    import java.util.Scanner;
    public class Invoice
    {
    public static void main (String args[])
    {
    int itemnum, quantitynum, totalcost;
    int price;
    String itemname;
    Scanner input = new Scanner(System.in);

    System.out.println("Please enter the items name");
    itemname = input.next();

    System.out.println("Please enter the items id");
    itemnum = input.nextInt();

    System.out.println("Please enter the items cost");
    price = input.nextInt();

    System.out.println("Please enter the amount of items you would like manufactured");
    quantitynum = input.nextInt();

    totalcost = (price*quantitynum);

    System.out.println("Item Name:" + itemname);
    System.out.println("");

    System.out.println("Item ID:" + itemnum);
    System.out.println("");


    System.out.println("Item Price:$" + price);
    System.out.println("");


    System.out.println("Items wanted:" + quantitynum);
    System.out.println("");


    System.out.println("Total Cost:$" + totalcost);
    System.out.println("");
    }
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How would I write this in Java?

    Do you have a question associated with this? Posting a homework question with some code without asking a defined question about either doesn't help us guide you with where you are stuck.

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How would I write this in Java?

    Like What would I need to write it my self....I'm don't under stand what I read but what I see, I under stand it when I see the code but can't begin writing it when I Read what needs to be done to get the end result. I have no Idea what the Technical terms are or what They look like in code.....All I know is when looking at code is I understand what it does. I don't know where to start when writing code.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How would I write this in Java?

    Start with a small, simple program like helloworld and build on it.
    You really don't learn until you write your own code and go thru all the problems you will have and fix those problems. Reading is a passive thing. Writing is active and you learn better.

Similar Threads

  1. Writing in a file using Java
    By JavaPF in forum File Input/Output Tutorials
    Replies: 4
    Last Post: December 17th, 2011, 04:33 PM
  2. How to write to specific part of an html file using java
    By nasi in forum File I/O & Other I/O Streams
    Replies: 12
    Last Post: May 27th, 2010, 11:22 PM
  3. Trying to write a Java OS for a course, myrad problems...
    By Tinito16 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 3rd, 2010, 02:51 AM
  4. Replies: 0
    Last Post: March 5th, 2010, 01:32 AM