<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'help with the do-wihle loop' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'help with the do-wihle loop' posted on the 'Java Beginners' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Thu, 20 Jun 2013 01:52:57 -0700</pubDate>
    <lastBuildDate>Thu, 20 Jun 2013 01:52:57 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418852/help-with-the-do-wihle-loop/</link>
      <description>Hello, I have been having a very hard time with this do while loop...it doesn't seem to work...it says cannot find symbol variable on the last line...can anybody help please?&lt;br /&gt;
&lt;br /&gt;
thank you&lt;br /&gt;
&lt;br /&gt;
	System.out.print("Please tell me how many people you are in your group: ");&lt;br /&gt;
    		double numberPeople=input.nextDouble();&lt;br /&gt;
			System.out.print("Thank you, now tell me the total cost of your meal: ");&lt;br /&gt;
			double totalCost=input.nextDouble();&lt;br /&gt;
			System.out.print("Thank you, now please tell me discount you were allotted in % form: ");&lt;br /&gt;
			double discount=input.nextDouble();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
			//Compute the given data&lt;br /&gt;
&lt;br /&gt;
			do{&lt;br /&gt;
			double worthDiscount=totalCost*(discount/100);//Calculate the total cost after the discount is given&lt;br /&gt;
			double amountGst=worthDiscount*GST;//Calculate the amount of Pst (cost after disc.*.05)&lt;br /&gt;
			double amountQst=(worthDiscount+amountGst)*QST;//Calculat
e the amount of Qst, so I did (cost after discount+Gst)*.075&lt;br /&gt;
			double totalPayableAmount=worthDiscount+amountGst+amountQ
st;&lt;br /&gt;
			double amountPaidByEach=totalPayableAmount/numberPeople;&lt;br /&gt;
&lt;br /&gt;
			//Output the results to console&lt;br /&gt;
			System.out.println("Your discount is "+discount+"%, which comes up to "+worthDiscount+"$.");&lt;br /&gt;
			System.out.println("Your subtotal price after discount is "+(totalCost-worthDiscount));&lt;br /&gt;
			System.out.println("You are "+numberPeople+ " people");&lt;br /&gt;
			System.out.println("The GST comes to "+amountGst+" $");&lt;br /&gt;
			System.out.println("The Qst comes to "+amountQst+"$");&lt;br /&gt;
			System.out.println("Your total price is "+(((totalCost-worthDiscount)*1.05)*1.075)+"$");&lt;br /&gt;
			System.out.println("The amount paid by each person is: "+(((((totalCost-worthDiscount)*1.05)*1.075))/numberPeople)+"$");&lt;br /&gt;
&lt;br /&gt;
			System.out.println("Would you like to repeat the calculation?");&lt;br /&gt;
			double answer=input.nextDouble();&lt;br /&gt;
			}&lt;br /&gt;
			while (answer=1);&lt;br /&gt;
&lt;br /&gt;
			}&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418852/help-with-the-do-wihle-loop/</guid>
      <pubDate>Mon, 27 Sep 2010 05:24:40 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418853/re-help-with-the-do-wihle-loop/#418853</link>
      <description>Use comparison operator '==' instead of assignment operator '=', it will solve your problem.&lt;br /&gt;
thanks!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418853/re-help-with-the-do-wihle-loop/#418853</guid>
      <pubDate>Mon, 27 Sep 2010 09:11:26 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418854/re-help-with-the-do-wihle-loop/#418854</link>
      <description>Also declare answer if you haven't!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418854/re-help-with-the-do-wihle-loop/#418854</guid>
      <pubDate>Mon, 27 Sep 2010 09:14:22 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418856/re-help-with-the-do-wihle-loop/#418856</link>
      <description>Thanks for the help, but when I declare the variable before that, it says that the answer is already defined in main (java.lang.String).&lt;br /&gt;
&lt;br /&gt;
import java.util.Scanner; //Import Scanner&lt;br /&gt;
&lt;br /&gt;
public class Restaurant_Ass1&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    public static void main (String[]args)&lt;br /&gt;
    	{&lt;br /&gt;
    		//Create Scanner&lt;br /&gt;
    		Scanner input=new Scanner(System.in);&lt;br /&gt;
&lt;br /&gt;
    		//ennumerate my constants&lt;br /&gt;
    		final double GST=0.05;&lt;br /&gt;
    		final double QST=0.075;&lt;br /&gt;
    		double answer;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    		//Ask for the needed information&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    		System.out.print("Please tell me how many people you are in your group: ");&lt;br /&gt;
    		double numberPeople=input.nextDouble();&lt;br /&gt;
			System.out.print("Thank you, now tell me the total cost of your meal: ");&lt;br /&gt;
			double totalCost=input.nextDouble();&lt;br /&gt;
			System.out.print("Thank you, now please tell me discount you were allotted in % form: ");&lt;br /&gt;
			double discount=input.nextDouble();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
			//Compute the given data&lt;br /&gt;
&lt;br /&gt;
			do{&lt;br /&gt;
			double worthDiscount=totalCost*(discount/100);//Calculate the total cost after the discount is given&lt;br /&gt;
			double amountGst=worthDiscount*GST;//Calculate the amount of Pst (cost after disc.*.05)&lt;br /&gt;
			double amountQst=(worthDiscount+amountGst)*QST;//Calculat
e the amount of Qst, so I did (cost after discount+Gst)*.075&lt;br /&gt;
			double totalPayableAmount=worthDiscount+amountGst+amountQ
st;&lt;br /&gt;
			double amountPaidByEach=totalPayableAmount/numberPeople;&lt;br /&gt;
&lt;br /&gt;
			//Output the results to console&lt;br /&gt;
			System.out.println("Your discount is "+discount+"%, which comes up to "+worthDiscount+"$.");&lt;br /&gt;
			System.out.println("Your subtotal price after discount is "+(totalCost-worthDiscount));&lt;br /&gt;
			System.out.println("You are "+numberPeople+ " people");&lt;br /&gt;
			System.out.println("The GST comes to "+amountGst+" $");&lt;br /&gt;
			System.out.println("The Qst comes to "+amountQst+"$");&lt;br /&gt;
			System.out.println("Your total price is "+(((totalCost-worthDiscount)*1.05)*1.075)+"$");&lt;br /&gt;
			System.out.println("The amount paid by each person is: "+(((((totalCost-worthDiscount)*1.05)*1.075))/numberPeople)+"$");&lt;br /&gt;
&lt;br /&gt;
			System.out.println("Would you like to repeat the calculation?");&lt;br /&gt;
			double answer=input.nextDouble();&lt;br /&gt;
			}&lt;br /&gt;
			while (answer==1);&lt;br /&gt;
&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418856/re-help-with-the-do-wihle-loop/#418856</guid>
      <pubDate>Mon, 27 Sep 2010 16:06:28 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418858/re-help-with-the-do-wihle-loop/#418858</link>
      <description>hmmmmm what are the exact outputs can you paste the error msgs?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418858/re-help-with-the-do-wihle-loop/#418858</guid>
      <pubDate>Tue, 28 Sep 2010 00:59:58 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418859/re-help-with-the-do-wihle-loop/#418859</link>
      <description>sorry! i haven't seen that you have already declared the answer before the closing '{' of do while ,just omit the double before the 'answer' variable inside while loop. &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418859/re-help-with-the-do-wihle-loop/#418859</guid>
      <pubDate>Tue, 28 Sep 2010 01:05:13 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418860/re-help-with-the-do-wihle-loop/#418860</link>
      <description>i think its ok now take care!</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418860/re-help-with-the-do-wihle-loop/#418860</guid>
      <pubDate>Tue, 28 Sep 2010 01:06:44 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418863/re-help-with-the-do-wihle-loop/#418863</link>
      <description>1000 times, thank you!!</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418863/re-help-with-the-do-wihle-loop/#418863</guid>
      <pubDate>Tue, 28 Sep 2010 05:19:15 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>This post has been deleted.</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418864/this-post-has-been-deleted/#418864</link>
      <description>This post has been deleted.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418864/this-post-has-been-deleted/#418864</guid>
      <pubDate>Tue, 28 Sep 2010 05:21:05 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>This post has been deleted.</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418865/this-post-has-been-deleted/#418865</link>
      <description>This post has been deleted.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418865/this-post-has-been-deleted/#418865</guid>
      <pubDate>Tue, 28 Sep 2010 05:22:44 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418871/re-help-with-the-do-wihle-loop/#418871</link>
      <description>What you told me works, but now there is another problem...I am trying to make this work... It is a problem where the user must enter an answer in order to restart or finish the program...when I use numbers, it works fine, (1 or 2) but when I use "y" or "n", there are errors that come out: &lt;br /&gt;
&lt;br /&gt;
Exception in thread "main" java.util.InputMismatchException&lt;br /&gt;
	at java.util.Scanner.throwFor(Scanner.java:840)&lt;br /&gt;
	at java.util.Scanner.next(Scanner.java:1461)&lt;br /&gt;
	at java.util.Scanner.nextDouble(Scanner.java:2387)&lt;br /&gt;
	at Restaurant_Ass1.main(Restaurant_Ass1.java:54)&lt;br /&gt;
&lt;br /&gt;
Process completed.&lt;br /&gt;
&lt;br /&gt;
I know this must be a really simple thing, but I have no idea what, I have been trying everything, but it only works with numbers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.util.Scanner; //Import Scanner&lt;br /&gt;
&lt;br /&gt;
public class Restaurant_Ass1&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    public static void main (String[]args)&lt;br /&gt;
    	{&lt;br /&gt;
    		//Create Scanner&lt;br /&gt;
    		Scanner input=new Scanner(System.in);&lt;br /&gt;
&lt;br /&gt;
    		//ennumerate my constants&lt;br /&gt;
    		final double GST=0.05;&lt;br /&gt;
    		final double QST=0.075;&lt;br /&gt;
    		double answer;&lt;br /&gt;
&lt;br /&gt;
    		//Ask for the needed information&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
			do{   //loop in case answer==y&lt;br /&gt;
    		System.out.print("Please tell me how many people you are in your group: ");&lt;br /&gt;
    		double numberPeople=input.nextDouble();&lt;br /&gt;
			System.out.print("Thank you, now tell me the total cost of your meal: ");&lt;br /&gt;
			double totalCost=input.nextDouble();&lt;br /&gt;
			System.out.print("Thank you, now please tell me the discount you were allotted in % form: ");&lt;br /&gt;
			double discount=input.nextDouble();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
			//Compute the given dataSystem.out.printf("Total spendings: %5.2f",total);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
			double worthDiscount=totalCost*(discount/100);//Calculate the total cost after the discount is given&lt;br /&gt;
			double amountGst=worthDiscount*GST;//Calculate the amount of Pst (cost after disc.*.05)&lt;br /&gt;
			double amountQst=(worthDiscount+amountGst)*QST;//Calculat
e the amount of Qst, so I did (cost after discount+Gst)*.075&lt;br /&gt;
			double totalPayableAmount=worthDiscount+amountGst+amountQ
st;// Calculate amount payable in total&lt;br /&gt;
			double amountPaidByEach=totalPayableAmount/numberPeople;/
/ Calculate amount paid by each member&lt;br /&gt;
&lt;br /&gt;
			//Output the results to console&lt;br /&gt;
			System.out.printf("Your discount is $ %5.2f\n",worthDiscount);&lt;br /&gt;
			System.out.printf("Your subtotal price after discount is $%5.2f\n",(totalCost-worthDiscount));&lt;br /&gt;
			System.out.printf("The GST comes to $ %5.2f\n",amountGst);&lt;br /&gt;
			System.out.printf("The Qst comes to $ %5.2f\n",amountQst);&lt;br /&gt;
			System.out.printf("Your total price is $ %5.2f\n",(((totalCost-worthDiscount)*1.05)*1.075));&lt;br /&gt;
			System.out.printf("The amount paid by each person is $ %5.2f\n",(((((totalCost-worthDiscount)*1.05)*1.075))/numberPeople));&lt;br /&gt;
&lt;br /&gt;
			do{     //loop in case answer!=y||n&lt;br /&gt;
&lt;br /&gt;
			System.out.println("Would you like to repeat the calculation?");&lt;br /&gt;
			answer=input.nextDouble();&lt;br /&gt;
			if(answer=='n')&lt;br /&gt;
			{break;&lt;br /&gt;
			}&lt;br /&gt;
				else if (answer!='y')&lt;br /&gt;
				{System.out.printf("I am sorry, but you input"+answer+"\n This is not valid. Please try again.\n");&lt;br /&gt;
				}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
			}&lt;br /&gt;
			while (answer!='y');&lt;br /&gt;
&lt;br /&gt;
			}&lt;br /&gt;
			while (answer=='y');&lt;br /&gt;
    	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418871/re-help-with-the-do-wihle-loop/#418871</guid>
      <pubDate>Tue, 28 Sep 2010 07:37:21 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418873/re-help-with-the-do-wihle-loop/#418873</link>
      <description>use read() on an inputStreamReader opject for reading a single character(byte[]) at a time....!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418873/re-help-with-the-do-wihle-loop/#418873</guid>
      <pubDate>Tue, 28 Sep 2010 09:11:02 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: help with the do-wihle loop</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/418852/418883/re-help-with-the-do-wihle-loop/#418883</link>
      <description>ok, but do I have to import anything first?</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/418852/418883/re-help-with-the-do-wihle-loop/#418883</guid>
      <pubDate>Wed, 29 Sep 2010 05:11:46 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
  </channel>
</rss>