My first program = Quiz :D
- From: ericmiranda7@xxxxxxxxx
- Date: Sun, 1 Jul 2012 09:18:55 -0700 (PDT)
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.
.
- Follow-Ups:
- Re: My first program = Quiz :D
- From: Roedy Green
- Re: My first program = Quiz :D
- From: ericmiranda7
- Re: My first program = Quiz :D
- From: Patricia Shanahan
- Re: My first program = Quiz :D
- Prev by Date: Re: Whay IDE am I supposed to use/is the best?
- Next by Date: Re: My first program = Quiz :D
- Previous by thread: Whay IDE am I supposed to use/is the best?
- Next by thread: Re: My first program = Quiz :D
- Index(es):
Relevant Pages
|