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("");
}
}
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.
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.
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.