Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1921
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!204.52.135.9.MISMATCH!newsfeed.hal-mli.net!feeder1.hal-mli.net!69.16.185.16.MISMATCH!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
|---|---|
| From | ericmiranda7@gmail.com |
| Newsgroups | comp.lang.java.help |
| Subject | Re: My first program = Quiz :D |
| Date | Sun, 1 Jul 2012 09:47:59 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 196 |
| Message-ID | <e50579ae-836c-46c5-952b-0cfdbfcbd7a8@googlegroups.com> (permalink) |
| References | <9c74bdc0-3238-4124-afcf-154eb305e5ae@googlegroups.com> <Cb-dnTP1TplI5m3SnZ2dnUVZ_hudnZ2d@earthlink.com> |
| NNTP-Posting-Host | 116.74.76.162 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Trace | posting.google.com 1341161386 10059 127.0.0.1 (1 Jul 2012 16:49:46 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Sun, 1 Jul 2012 16:49:46 +0000 (UTC) |
| In-Reply-To | <Cb-dnTP1TplI5m3SnZ2dnUVZ_hudnZ2d@earthlink.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=116.74.76.162; posting-account=2qZB9woAAAA0INrON0_PW3oGBF9qAGy2 |
| User-Agent | G2/1.0 |
| X-Received-Bytes | 7308 |
| Xref | csiph.com comp.lang.java.help:1921 |
Show key headers only | View raw
On Sunday, July 1, 2012 10:03:25 PM UTC+5:30, Patricia Shanahan wrote:
> On 7/1/2012 9:18 AM, ericmiranda7@gmail.com wrote:
> > Alright, here is my first program. Just testing it.
> >
> > ----------------------------------------
> > import java.util.Scanner;
> > public class quiz {
> >
> > /**
> > * @param args
> > */
> > public static void main(String[] args) {
> > // TODO Auto-generated method stub
> > Scanner myScanner = new Scanner(System.in);
> >
> > String thisString;
> > double points = 0;
> > double total;
> >
> > System.out.println("Did Germany win vs. Portugal? Yes or no");
> > thisString = myScanner.nextLine();
> >
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct! Plus points!");
> > total = points + 1;
> > System.out.println("Is the Galaxy Tab android?");
> > thisString = myScanner.nextLine();
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct. Plus points!");
> > total = points + 1;
> > }
> > }
> > }
> > }
> > ---------------------------------------------------------
> > Now, my question is -
> > I wrote the statement(total = points + 1;)twice. Even though I answered "yes
> > (the correct answer to each question)twice my total points came to 1. Should they not add up and become two? Thank-you for the answers.
> >
>
> points is always zero - none of your code changes it - so (points + 1)
> is always one.
>
> Why the separate variables "points" and "total"?
>
> Patricia
I'm a newbie, and I really don't know why I did that. Could you tell me how to update the points variable? I'd much appreciate it. Thanks.
On Sunday, July 1, 2012 10:03:25 PM UTC+5:30, Patricia Shanahan wrote:
> On 7/1/2012 9:18 AM, ericmiranda7@gmail.com wrote:
> > Alright, here is my first program. Just testing it.
> >
> > ----------------------------------------
> > import java.util.Scanner;
> > public class quiz {
> >
> > /**
> > * @param args
> > */
> > public static void main(String[] args) {
> > // TODO Auto-generated method stub
> > Scanner myScanner = new Scanner(System.in);
> >
> > String thisString;
> > double points = 0;
> > double total;
> >
> > System.out.println("Did Germany win vs. Portugal? Yes or no");
> > thisString = myScanner.nextLine();
> >
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct! Plus points!");
> > total = points + 1;
> > System.out.println("Is the Galaxy Tab android?");
> > thisString = myScanner.nextLine();
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct. Plus points!");
> > total = points + 1;
> > }
> > }
> > }
> > }
> > ---------------------------------------------------------
> > Now, my question is -
> > I wrote the statement(total = points + 1;)twice. Even though I answered "yes
> > (the correct answer to each question)twice my total points came to 1. Should they not add up and become two? Thank-you for the answers.
> >
>
> points is always zero - none of your code changes it - so (points + 1)
> is always one.
>
> Why the separate variables "points" and "total"?
>
> Patricia
On Sunday, July 1, 2012 10:03:25 PM UTC+5:30, Patricia Shanahan wrote:
> On 7/1/2012 9:18 AM, ericmiranda7@gmail.com wrote:
> > Alright, here is my first program. Just testing it.
> >
> > ----------------------------------------
> > import java.util.Scanner;
> > public class quiz {
> >
> > /**
> > * @param args
> > */
> > public static void main(String[] args) {
> > // TODO Auto-generated method stub
> > Scanner myScanner = new Scanner(System.in);
> >
> > String thisString;
> > double points = 0;
> > double total;
> >
> > System.out.println("Did Germany win vs. Portugal? Yes or no");
> > thisString = myScanner.nextLine();
> >
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct! Plus points!");
> > total = points + 1;
> > System.out.println("Is the Galaxy Tab android?");
> > thisString = myScanner.nextLine();
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct. Plus points!");
> > total = points + 1;
> > }
> > }
> > }
> > }
> > ---------------------------------------------------------
> > Now, my question is -
> > I wrote the statement(total = points + 1;)twice. Even though I answered "yes
> > (the correct answer to each question)twice my total points came to 1. Should they not add up and become two? Thank-you for the answers.
> >
>
> points is always zero - none of your code changes it - so (points + 1)
> is always one.
>
> Why the separate variables "points" and "total"?
>
> Patricia
On Sunday, July 1, 2012 10:03:25 PM UTC+5:30, Patricia Shanahan wrote:
> On 7/1/2012 9:18 AM, ericmiranda7@gmail.com wrote:
> > Alright, here is my first program. Just testing it.
> >
> > ----------------------------------------
> > import java.util.Scanner;
> > public class quiz {
> >
> > /**
> > * @param args
> > */
> > public static void main(String[] args) {
> > // TODO Auto-generated method stub
> > Scanner myScanner = new Scanner(System.in);
> >
> > String thisString;
> > double points = 0;
> > double total;
> >
> > System.out.println("Did Germany win vs. Portugal? Yes or no");
> > thisString = myScanner.nextLine();
> >
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct! Plus points!");
> > total = points + 1;
> > System.out.println("Is the Galaxy Tab android?");
> > thisString = myScanner.nextLine();
> > if (thisString.equals("Yes")) {
> > System.out.println("That is correct. Plus points!");
> > total = points + 1;
> > }
> > }
> > }
> > }
> > ---------------------------------------------------------
> > Now, my question is -
> > I wrote the statement(total = points + 1;)twice. Even though I answered "yes
> > (the correct answer to each question)twice my total points came to 1. Should they not add up and become two? Thank-you for the answers.
> >
>
> points is always zero - none of your code changes it - so (points + 1)
> is always one.
>
> Why the separate variables "points" and "total"?
>
> Patricia
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
My first program = Quiz :D ericmiranda7@gmail.com - 2012-07-01 09:18 -0700
Re: My first program = Quiz :D Patricia Shanahan <pats@acm.org> - 2012-07-01 09:33 -0700
Re: My first program = Quiz :D ericmiranda7@gmail.com - 2012-07-01 09:47 -0700
Re: My first program = Quiz :D Patricia Shanahan <pats@acm.org> - 2012-07-01 09:57 -0700
Re: My first program = Quiz :D markspace <-@.> - 2012-07-01 10:11 -0700
Re: My first program = Quiz :D Lew <noone@lewscanon.com> - 2012-07-01 10:20 -0700
Re: My first program = Quiz :D ericmiranda7@gmail.com - 2012-07-01 10:20 -0700
Re: My first program = Quiz :D Patricia Shanahan <pats@acm.org> - 2012-07-01 10:59 -0700
Re: My first program = Quiz :D Roedy Green <see_website@mindprod.com.invalid> - 2012-07-03 05:16 -0700
Re: My first program = Quiz :D Roedy Green <see_website@mindprod.com.invalid> - 2012-07-01 17:02 -0700
csiph-web