Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1920
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!204.52.135.9.MISMATCH!newsfeed.hal-mli.net!feeder1.hal-mli.net!216.196.98.142.MISMATCH!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Sun, 01 Jul 2012 11:33:25 -0500 |
| Date | Sun, 01 Jul 2012 09:33:25 -0700 |
| From | Patricia Shanahan <pats@acm.org> |
| User-Agent | Mozilla/5.0 (Windows NT 5.2; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.help |
| Subject | Re: My first program = Quiz :D |
| References | <9c74bdc0-3238-4124-afcf-154eb305e5ae@googlegroups.com> |
| In-Reply-To | <9c74bdc0-3238-4124-afcf-154eb305e5ae@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Message-ID | <Cb-dnTP1TplI5m3SnZ2dnUVZ_hudnZ2d@earthlink.com> (permalink) |
| Lines | 45 |
| X-Usenet-Provider | http://www.giganews.com |
| NNTP-Posting-Host | 70.230.202.8 |
| X-Trace | sv3-Zq8KOOBrFO6o0JA1ab0lRuBzlcbQM10X3DJuBFPRVpd576DwZdz5L8cGkL2pVzEGF58ZHOKr5aAWAbt!lNObVsfXoY8NI+XzfydK2CRdpFIShtP82GXQdx9jFvxW2gVsZwPU1nryzimZWP542I5tit/Yo5FV!nPM2mXD7r4t/DX19bCIJpXX5rTcMzOa8hf6XX+iCnFZV |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 2551 |
| Xref | csiph.com comp.lang.java.help:1920 |
Show key headers only | View raw
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