8 Replies - 2034 Views - Last Post: 23 November 2008 - 11:04 PM Rate Topic: -----

#1 GK14   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 23-November 08

urgent: loops problems for purchasing/receipt program

Post icon  Posted 23 November 2008 - 07:23 PM

I am taking a grade 10 computers course at my school and we need to make a program that gathers input from the user, telling the computer what he/she bought and what the price was. We then have to make a receipt for the purchases. I am trying to give the user the option to buy up to ten items, instead of giving him a "you have to buy 4" sort of message. Only thing is I can't figure out how to make all those loops work. I tried doing multiple while loops but im not sure if it is working. Each time I'm trying to say that if the string is equal to Y, y, yes, Yes than the customer may buy something else.

This is what I came up with but im getting upwards of 70 errors. Please help!

String itemcode1, itemcode2, itemcode3, itemcode4, itemcode5;
		String itemcode6, itemcode7, itemcode8, itemcode9, itemcode10;
		int price1, price2, price3, price4, price5, price6;
		int price7, price8, price9, price10;
		char another1, another2, another3, another4, another5;
		char another6, another7, another8, another9;
		
		System.out.println("PURCHASE");									
		System.out.print("\n\n\n\nPlease enter the item code: ");
		itemcode1 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price1 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another1 = In.getChar();
		
		while(another1.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode2 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price2 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): "
		another2 = In.getChar();
		
		while(another2.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode3 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price3 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another3 = In.getChar();
		
		while(another3.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode4 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price4 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another4 = In.getChar();
		
		while(another4.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode5 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price5 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another5 = In.getChar();
		
		while(another5.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode6 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price6 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another6 = In.getChar();
		
		while(another6.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode7 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price7 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another7 = In.getChar();
		
		while(another7.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode8 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price8 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another8 = In.getChar();
		
		while(another8.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode9 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price9 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another9 = In.getChar();
		
		while(another9.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode10 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price10 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.println("\n\nThat is the maximum amount of purchases you can make at this time. ");
	}
	System.out.println("receipt would go here...!");
	} 


also, i believe this is how you send a file, you have to zip it right?

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: urgent: loops problems for purchasing/receipt program

#2 n8wxs   User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 09:19 PM

View PostGK14, on 23 Nov, 2008 - 06:23 PM, said:

I am taking a grade 10 computers course at my school and we need to make a program that gathers input from the user, telling the computer what he/she bought and what the price was. We then have to make a receipt for the purchases. I am trying to give the user the option to buy up to ten items, instead of giving him a "you have to buy 4" sort of message. Only thing is I can't figure out how to make all those loops work. I tried doing multiple while loops but im not sure if it is working. Each time I'm trying to say that if the string is equal to Y, y, yes, Yes than the customer may buy something else.

This is what I came up with but im getting upwards of 70 errors. Please help!
String itemcode1, itemcode2, itemcode3, itemcode4, itemcode5;
		String itemcode6, itemcode7, itemcode8, itemcode9, itemcode10;
		int price1, price2, price3, price4, price5, price6;
		int price7, price8, price9, price10;
		char another1, another2, another3, another4, another5;
		char another6, another7, another8, another9;
		
		System.out.println("PURCHASE");									
		System.out.print("\n\n\n\nPlease enter the item code: ");
		itemcode1 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price1 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another1 = In.getChar();		
		while(another1.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode2 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price2 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): "
		another2 = In.getChar();
		
		while(another2.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode3 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price3 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another3 = In.getChar();
		
		while(another3.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode4 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price4 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another4 = In.getChar();
		
		while(another4.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode5 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price5 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another5 = In.getChar();
		
		while(another5.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode6 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price6 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another6 = In.getChar();
		
		while(another6.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode7 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price7 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another7 = In.getChar();
		
		while(another7.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode8 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price8 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another8 = In.getChar();
		
		while(another8.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode9 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price9 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another9 = In.getChar();
		
		while(another9.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode10 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price10 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.println("\n\nThat is the maximum amount of purchases you can make at this time. ");
	}
	System.out.println("receipt would go here...!");
	}



also, i believe this is how you send a file, you have to zip it right?


Where is public static void main(String[] args) { ?
Where is In; declared?

This post has been edited by n8wxs: 23 November 2008 - 09:19 PM

Was This Post Helpful? 0
  • +
  • -

#3 GK14   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 23-November 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 09:21 PM

View Postn8wxs, on 23 Nov, 2008 - 08:19 PM, said:

View PostGK14, on 23 Nov, 2008 - 06:23 PM, said:

I am taking a grade 10 computers course at my school and we need to make a program that gathers input from the user, telling the computer what he/she bought and what the price was. We then have to make a receipt for the purchases. I am trying to give the user the option to buy up to ten items, instead of giving him a "you have to buy 4" sort of message. Only thing is I can't figure out how to make all those loops work. I tried doing multiple while loops but im not sure if it is working. Each time I'm trying to say that if the string is equal to Y, y, yes, Yes than the customer may buy something else.

This is what I came up with but im getting upwards of 70 errors. Please help!
String itemcode1, itemcode2, itemcode3, itemcode4, itemcode5;
		String itemcode6, itemcode7, itemcode8, itemcode9, itemcode10;
		int price1, price2, price3, price4, price5, price6;
		int price7, price8, price9, price10;
		char another1, another2, another3, another4, another5;
		char another6, another7, another8, another9;
		
		System.out.println("PURCHASE");									
		System.out.print("\n\n\n\nPlease enter the item code: ");
		itemcode1 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price1 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another1 = In.getChar();		
		while(another1.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode2 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price2 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): "
		another2 = In.getChar();
		
		while(another2.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode3 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price3 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another3 = In.getChar();
		
		while(another3.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode4 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price4 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another4 = In.getChar();
		
		while(another4.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode5 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price5 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another5 = In.getChar();
		
		while(another5.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode6 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price6 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another6 = In.getChar();
		
		while(another6.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode7 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price7 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another7 = In.getChar();
		
		while(another7.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode8 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price8 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another8 = In.getChar();
		
		while(another8.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode9 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price9 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another9 = In.getChar();
		
		while(another9.charAt(0)=='Y'||object1.charAt(0)=='y'||object1.charAt(0)=='yes'||object1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode10 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price10 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.println("\n\nThat is the maximum amount of purchases you can make at this time. ");
	}
	System.out.println("receipt would go here...!");
	}



also, i believe this is how you send a file, you have to zip it right?


Where is public static void main(String[] args) { ?
Where is In; declared?


I should have been more specific, sorry. I just posted the block of text that was getting the errors. Also, my teacher gave me 2 other files, In.java and Out.java to declare In; and such. I have attached that whole file if you want to take an in depth look at my problem...
Was This Post Helpful? 0
  • +
  • -

#4 DaneAU   User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,620
  • Joined: 15-May 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 09:24 PM

Yea i am pretty sure you would recieve a lot of errors. Please post the entire code... Please post the entire source because i can see a lot of errors just at first site ;)

The attachment didn't contain those files

This post has been edited by bbq: 23 November 2008 - 09:25 PM

Was This Post Helpful? 1
  • +
  • -

#5 GK14   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 23-November 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 09:36 PM

Here is the full text

 

/**
 * @(#)HonestGavs.java
 *
 * HonestGavs application
 *
 * @author 
 * @version 1.00 2008/11/6
 */
 
public class HonestGavs
	

{
	
	public static void main(String[] args) 
   	{
		new HonestGavs();
	}
	
	HonestGavs()
	{
		char choice;
		
	//this starts the loop for the menu
		title();
		pause();
		do
		{
			clear();
			menu();
			choice = In.getChar();
			clear();
			switch(choice)
			{
				//declares the characters used for the menu.
				case 'i':
				case 'I':
					instructions();
					break;
				case 'c':
				case 'C':
					catalogue();
					break;
				case 'p':
				case 'P':
					purchase();
					break;
				case 'x':
				case 'X':
					exit();
					break;
					//if the user enters a different character, then the defualt screen will appear.
				default:
					System.out.println("								 __ ");
					System.out.println("					   _ ,___,-'\",-=-. ");
					System.out.println("		   __,-- _ _,-'_)_  (\"\"`'-._\\ `. ");
					System.out.println("		_,'  __ |,' ,-' __)  ,-	 /. | ");
					System.out.println("	  ,'_,--'   |	 -'  _)/		 `\\ ");
					System.out.println("	,','	  ,'	   ,-'_,`		   : ");
					System.out.println("	,'	 ,-'	   ,(,-(			  : ");
					System.out.println("		 ,'	   ,-' ,	_		   ; ");
					System.out.println("		/		,-._/`---'			/ ");
					System.out.println("	   /		(____)(----. )	   ,' ");
					System.out.println("	  /		 (	  `.__,	 /\\ /, ");
					System.out.println("	 :		  ;-.___		 /__\\/| ");
					System.out.println("	 |		 ,'	  `--.	  -,\\ | ");
					System.out.println("	 :		/			\\	.__/");
					System.out.println("	  \\	  (__			\\	|_ ");
					System.out.println("	   \\	   ,`-, *	   /   _|,\\ ");
					System.out.println("		\\	,'   `-.	 ,'_,-'	\\ ");
					System.out.println("	   (_\\,-'	,'\\\")--,'-'	   __\\ ");
					System.out.println("		\\	   /  // ,'|	  ,--'  `-. ");
					System.out.println("		 `-.	`-/ \\'  |   _,'		 `. ");
					System.out.println("			`-._ /	  `--'/			 \\ ");
					System.out.println("	-hrr-	  ,'		   |			  \\ ");
					System.out.println("			  /			 |			   \\ ");
					System.out.println("		   ,-'			  |			   / ");
					System.out.println("		  /				 |			 -' ");
					System.out.println("\n\n");
					System.out.println("   Come on! the intructions are pretty easy to follow. TRY AGAIN!");
			}
			pause();
		}while(choice!='x'&&choice!='X');
	}
							   
	public void clear()
	{
		System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
	}
	
	public void pause()
	{
		System.out.print("Please press the ENTER key to continue...");
		In.getChar();
	}
	
	public void title()
	{
		//This displays the Title
			System.out.println("\n	,-_/,. ,,--. ,-,-.   .-,--. .---. ,--,--'   ,---.	  ,.   ,.   ,. . .---."); 
			System.out.println("	' |_|/ |`, | ` | |	`\\__  \\___  `- |	  |  -'	 / |   `|  /   ' \\___  ");
			System.out.println("	 /| |  |   |   | |-.   /		\\  , |	  |  ,-'   /~~|-.  | /		  \\ ");
			System.out.println("	 `' `' `---'  ,' `-'  '`--' `---'  `-'	  `---|  ,'   `-'  `'	   `---' ");
			System.out.println("												 ,-.|						   ");
			System.out.println("												 `-+'						   ");
			System.out.println("\n\n");
			System.out.println("				,			_..._			,");
			System.out.println("				   {'.		 .'	 '.		 .'}");
			System.out.println("				  { ~ '.	  _|=	__|_	  .'  ~}");
			System.out.println("				 { ~  ~ '-._ (___________) _.-'~  ~  }");
			System.out.println("				{~  ~  ~   ~.'		   '. ~	~	}");
			System.out.println("			   {  ~   ~  ~ /   /\\	 /\\   \\   ~	~  }");
			System.out.println("			   {   ~   ~  /	__	 __	\\ ~   ~	}");
			System.out.println("				{   ~  /\\/  -<( o)   ( o)>-  \\/\\ ~   ~}");
			System.out.println("		 		 { ~  ;(	  \\/ .-. \\/	  );   ~ }");
			System.out.println("				  { ~ ~\\_  ()  ^ (   ) ^  ()  _/ ~  }");
			System.out.println("				   '-._~ \\   (`-._'-'_.-')   / ~_.-'");
			System.out.println("					   '--\\   `'._'\"'_.'`   /--'");
			System.out.println("						   \\	 \\`-'/	 /");
			System.out.println("							`\\	'-'	/'");
			System.out.println("						jgs   `\\	   /'");
			System.out.println("								'-...-'");
			System.out.println("	 '||''''|  '||					.							 ||		  ");
			System.out.println("	  ||  .	 ||	....	....  .||.  ... ..	...   .. ...   ...	....	....");
			System.out.println("	  ||''|	 ||  .|...|| .|   ''  ||	||' '' .|  '|.  ||  ||   ||  .|   ''  ||. ' ");
			System.out.println("	  ||		||  ||	  ||	   ||	||	 ||   ||  ||  ||   ||  ||	   . '|.. ");
			System.out.println("	 .||.....| .||.  '|...'  '|...'  '|.' .||.	 '|..|' .||. ||. .||.  '|...'  |'..|' ");
			System.out.println("\n");
			System.out.println("		  '||''''|									   ||					  ");
			System.out.println("		   ||  .	.. .. ..   ... ...	...   ... ..  ...  ... ...  .. .. ..   ");
			System.out.println("		   ||''|	 || || ||   ||'  || .|  '|.  ||' ''  ||   ||  ||   || || ||  ");
			System.out.println("		   ||		|| || ||   ||	| ||   ||  ||	  ||   ||  ||   || || ||  ");
			System.out.println("		  .||.....| .|| || ||.  ||...'   '|..|' .||.	.||.  '|..'|. .|| || ||. ");
			System.out.println("	 				||											   ");
			System.out.println("				   ''''											  ");



			System.out.println(" ");
	}	
	
	public void menu()
	{

			
			
			System.out.println("		MENU");
			System.out.println("\n\n");
			System.out.println("   I) Instructions");
			System.out.println("   C) Catalogue");
			System.out.println("   P) Purchase");
			System.out.println("   X) Exit the program");
			System.out.print("   Enter your choice: ");
	}
	
	public void instructions()
	{
		System.out.println("All the prices are non-negotiable as the mechandise is already ridiculously CHEAP!");
		
	}
	
	public void catalogue()
	{
		System.out.println("\t\t\t\t\t____ ____ ___ ____ _	____ ____ _  _ ____ ");
		System.out.println("\t\t\t\t\t|	|__|  |  |__| |	|  | | __ |  | |___ ");
		System.out.println("\t\t\t\t\t|___ |  |  |  |  | |___ |__| |__] |__| |___ ");
		System.out.println("\n\n");
		System.out.println("	___________________________	   ___________________________	  ___________________________");
		System.out.println("   |SONY BRAVIA LCD Z-SERIES TV|	 |SONY BRAVIA LCD R-SERIES TV|	|SONY BRAVIA LCD L-SERIES TV|");
		System.out.println("   |	  ITEM #: 112334	   |	 |	  ITEM #: 112335	   |	|		ITEM #: 112336	 |");
		System.out.println("   |		  $109.99		  |	 |		   $89.98		  |	|		   $101.99		 |");
		System.out.println("   |___________________________|	 |___________________________|	|___________________________|");
		System.out.println("			________________________		__________________		  ______________		");
		System.out.println("		   |SONY PLAYSTATION 3 (PS3)|	  |MICROSOFT XBOX 360|		| NINTENDO WII |");
		System.out.println("		   |	 ITEM #: 110110	 |	  |  ITEM #: 110111  |		|ITEM #: 110112|");
		System.out.println("		   |		 $51.99		 |	  |	  $42.05	  |		|	 $44.00   |");
		System.out.println("		   |________________________|	  |__________________|		|______________|");
		System.out.println("						 ________________	  _________________________");
		System.out.println("						|NINTENDO DS LITE|	|PLAYSATION PORTABLE (PSP)| ");
		System.out.println("						| ITEM #: 989897 |	|	 ITEM #: 989898	  |");
		System.out.println("						|	 $31.09	 |	|		 $37.99		  |");
		System.out.println("						|________________|	|_________________________|");
		System.out.println("			________________		______________	   _______________________");
		System.out.println("		   |POKEMON PLATINUM|	  |	HALO 3	|	 |STAR WARS BATTLEFRONT 2|");
		System.out.println("		   |  (NINTENDO DS) |	  |  (XBOX 360)  |	 | (XBOX 360, PS3, PSP)  | 	 	");
		System.out.println("		   | ITEM #: 967111 |	  |ITEM #: 967112|	 |	 ITEM #: 967113	|");
		System.out.println("		   |	 $19.99	 |	  |	$11.99	|	 |		 $19.49		|");
		System.out.println("		   |________________|	  |______________|	 |_______________________|");
		System.out.println("	__________________			   ________________				 __________________				");
		System.out.println("   |APPLE 'IPOD TOUCH'|				| APPLE 'IPHONE' |			   |APPLE 'IPOD VIDEO'|");
		System.out.println("   |  ITEM #: 334566  |			 | ITEM #: 334567 |			   |  ITEM #: 334568  |");
		System.out.println("   |	  $69.99	  |			 |	 $74.98	 |			   |	   $59.99	 |");
		System.out.println("   |__________________|			 |________________|			   |__________________|");
					
	}
	
	public void purchase()
	{
		String itemcode1, itemcode2, itemcode3, itemcode4, itemcode5, itemcode6, itemcode7, itemcode8, itemcode9, itemcode10;
		double price1, price2, price3, price4, price5, price6, price7, price8, price9, price10;
		double tax, subtotal, total;
		char another1, another2, another3, another4, another5, another6, another7, another8, another9, another10;

 
		
		System.out.print("								___  _  _ ____ ____ _  _ ____ ____ ____ ");
		System.out.print("								|__] |  | |__/ |	|__| |__| [__  |___ ");
		System.out.print("								|	|__| |  \\ |___ |  | |  | ___] |___ ");
		System.out.println("\n\n\n\n");
									
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another1 = In.getChar();
		
		while(another1.charAt(0)=='Y'||another1.charAt(0)=='y'||another1.charAt(0)=='yes'||another1.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode2 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price2 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): "
		another2 = In.getChar();
		
		while(another2.charAt(0)=='Y'||another2.charAt(0)=='y'||another2.charAt(0)=='yes'||another2.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode3 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price3 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another3 = In.getChar();
		
		while(another3.charAt(0)=='Y'||another3.charAt(0)=='y'||another3.charAt(0)=='yes'||another3.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode4 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price4 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another4 = In.getChar();
		
		while(another4.charAt(0)=='Y'||another4.charAt(0)=='y'||another4.charAt(0)=='yes'||another4.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode5 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price5 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another5 = In.getChar();
		
		while(another5.charAt(0)=='Y'||another5.charAt(0)=='y'||another5.charAt(0)=='yes'||another5.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode6 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price6 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another6 = In.getChar();
		
		while(another6.charAt(0)=='Y'||another6.charAt(0)=='y'||another6.charAt(0)=='yes'||another6.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode7 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price7 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another7 = In.getChar();
		
		while(another7.charAt(0)=='Y'||another7.charAt(0)=='y'||another7.charAt(0)=='yes'||another7.charAt(0)=='Yes')
		{System.out.print("Please enter the item code: ");
		itemcode8 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price8 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another8 = In.getChar();
		
		while(another8.charAt(0)=='Y'||another8.charAt(0)=='y'||another8.charAt(0)=='yes'||another8.charAt(0)=='Yes'); 
		{System.out.print("Please enter the item code: ");
		itemcode9 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price9 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.print("\n\nWould you like to make another purchase (Y/N): ");
		another9 = In.getChar();
		
		while(another9.charAt(0)=='Y'||another9.charAt(0)=='y'||another9.charAt(0)=='yes'||another9.charAt(0)=='Yes') 
		{System.out.print("Please enter the item code: ");
		itemcode10 = In.getString();
		
		System.out.print("Please enter item cost: ");
		price10 = In.getInt();
		
		System.out.println(itemcode1 + " at a price of $" + price1);
		
		System.out.println("\n\nThat is the maximum amount of purchases you can make at this time. ");
	  
	}
	System.out.println("it worked!");

		
	}
	
	public void exit()
	{
		
	}
	
}



do you also want me to post the contents of the other two files?

how many closing brackets do I need for those loops and how messed did I make them. I'm really struggling. please help! I couldn't dfind anything explaining anything that would help me do what I wanted to do...
Was This Post Helpful? 0
  • +
  • -

#6 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 09:43 PM

In is not defined like in:

choice = In.getChar();
Was This Post Helpful? 0
  • +
  • -

#7 GK14   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 23-November 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 09:47 PM

the file In.java I did not write this.

import java.io.*;
import java.text.*;

public class In
{
  static InputStreamReader r = new InputStreamReader(System.in);
  static BufferedReader br = new BufferedReader(r);

  // Read a String from standard system input
  public static String getString()
  {
	try
	{
	  return br.readLine();
	}
	catch (Exception e)
	{
	  return "";
	}
  }

  // Read a Number as a String from standard system input
  // Return the Number
  public static Number getNumber()
  {
	String numberString = getString();
	try
	{
	  numberString = numberString.trim().toUpperCase();
	  return NumberFormat.getInstance().parse(numberString );
	}
	catch (Exception e)
	{
	  // If any exception occurs, just return zero
	  return new Integer(0);
	}
  }

  // Read an int from standard system input
  public static int getInt ()
  {
	return getNumber().intValue();
  }

  // Read a long from standard system input
  public static long getLong ()
  {
	return getNumber().longValue();
  }

  // Read a float from standard system input
  public static float getFloat ()
  {
	return getNumber().floatValue();
  }

  // Read a double from standard system input
  public static double getDouble ()
  {
	return getNumber().doubleValue();
  }

  // Read a char from standard system input
  public static char getChar ()
  {
	String s = getString();
	if (s.length() >= 1)
	  return s.charAt(0);
	else
	  return '\n';
  }

}



is that what defines In?

please, I'm sorry if im being an annoyance but im really stressed and no matter how hard I try, I can't get this to work.
Was This Post Helpful? 0
  • +
  • -

#8 DaneAU   User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,620
  • Joined: 15-May 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 10:34 PM

in as in a scanner of some type i assume
Scanner In = new Scanner(System.in);



Was This Post Helpful? 0
  • +
  • -

#9 GK14   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 23-November 08

Re: urgent: loops problems for purchasing/receipt program

Posted 23 November 2008 - 11:04 PM

thank you for all your help, but I think i'm just going to make it simpler. I do, however, have a new question. If I were to provide and if statement saying that the amount payed was not sufficient to cover the cost, "you still owe:..." what the if statement be? if(change==LOWER THAN ZERO)System.out.print("You still owe: "): as shown below.

System.out.println("HONEST GAV’S\n\n");
Out.print(itemcode1,6);
System.out.print("\t\t\t");
Out.printCurrency(price1,5,2);
System.out.print("\n");
Out.print(itemcode2,6);
System.out.print("\t\t\t");
Out.printCurrency(price2,5,2);
System.out.print("\n");
Out.print(itemcode3,6);
System.out.print("\t\t\t");
Out.printCurrency(price3,5,2);
System.out.print("\n");
Out.print(itemcode4,6);
System.out.print("\t\t\t");
Out.printCurrency(price4,5,2);
System.out.print("\n");
Out.print(itemcode5,6);
System.out.print("\t\t\t");
Out.printCurrency(price5,5,2);
System.out.print("\n");
System.out.println("--------------------------------");
System.out.print("SUBTOTAL: \t\t");
subtotal=price1+price2+price3+price4+price5;
Out.printCurrency(subtotal,5,2);
tax=subtotal*0.13;
System.out.print("\nTAX:\t\t\t");
Out.printCurrency(tax,5,2);
total=tax+subtotal;
System.out.print("\nTOTAL:\t\t\t");
Out.printCurrency(total,5,2);
System.out.println("\n\n\n");
System.out.print("Amount given to cashier: ");
payment = In.getDouble();
System.out.print("\n");
change=payment-total;
payment2=change*(-1);
System.out.print("Change due: ");
Out.printCurrency(change,6,2);
[b]ifLOWER THAN 0[/b] System.out.print("\nYou still owe: ");
Out.printCurrency(payment2,5,2);
System.out.println("\n"); 


how would i say that mathematically. I've been trying for 20 minutes and can't come up with the right thing.

This post has been edited by GK14: 23 November 2008 - 11:07 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1