Results 1 to 7 of 7
Thread: help please
- 04-23-2009, 07:26 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
help please
i have a small program im working on for school could some one please help me and tell me were im goin wrong??
import java.util.*;
public class Assignment2
{
public static void main (String [] args)
{
Scanner input = new Scanner (System.in);
//variables
double product1 = 2.98;
double product2 = 4.50;
double product3 = 9.98;
double product4 = 4.49;
double product5 = 6.87;
double totalproduct1;
double totalproduct2;
double totalproduct3;
double totalproduct4;
double totalproduct5;
double total;
char answer;
int productCount;
int quanityproduct1;
int quanityproduct2;
int quanityproduct3;
int quanityproduct4;
int quanityproduct5;
// create loop
productCount = 0;
while (productCount < 6)
{
System.out.println("enter quantity for product1");
quanityproduct1 = Console.readInt();
System.out.println("enter quantity for product 2");
quanityproduct2 = Console.readInt();
System.out.println("enter quantity for product 3");
quanityproduct3 = Console.readInt();
System.out.println("enter quantity for product 4");
quanityproduct4 = Console.readInt();
System.out.println("enter quanity for product 5");
quanityproduct5 = Console.readInt();
productCount = productCount + 1;}
//calculate total
totalproduct1 = quanityproduct1 * product1;
totalproduct1 = quanityproduct2 * product2;
totalproduct1 = quanityproduct3 * product3;
totalproduct1 = quanityproduct4 * product4;
totalproduct1 = quanityproduct5 * product5;
total = totalproduct1 + totalproduct2 + totalproduct3 + totalproduct4 + totalproduct5;
System.out.println("total for all products is " + total);
}
}
im getting errors at all the "quanityproduct1 = Console.readInt();" the error is "cnnot find symbol". I dont know wot it is as far as i can tell the code should work,iv been told i could use arrays but im still very new and not quite that far,anyway any help would be great
- 04-23-2009, 07:27 PM #2
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
you should post the exact errors you get from the java if you want insight on them.
- 04-23-2009, 07:31 PM #3
You defined your scanner as input, not Console.
Try using input.readInt();
- 04-23-2009, 07:47 PM #4
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
still get them same errors,
- 04-23-2009, 08:41 PM #5
You also have to initialize your quantityproducts... And make sure that your scanner is input.nextInt(),
Also please post your errors...Who Cares... As Long As It Works...
- 04-23-2009, 08:58 PM #6
- 04-24-2009, 03:20 PM #7
Member
- Join Date
- Apr 2009
- Posts
- 15
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks