Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1925

Re: My first program = Quiz :D

From ericmiranda7@gmail.com
Newsgroups comp.lang.java.help
Subject Re: My first program = Quiz :D
Date 2012-07-01 10:20 -0700
Organization http://groups.google.com
Message-ID <fdfa4e75-4e4c-4df6-ac47-06fa88c1b721@googlegroups.com> (permalink)
References <9c74bdc0-3238-4124-afcf-154eb305e5ae@googlegroups.com>

Show all headers | View raw


On Sunday, July 1, 2012 9:48:55 PM UTC+5:30, ericmi...@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.

Oh uh-... No, this isn't a class project/assignment. I'm 15 Years, and I'm doing this as a hobby. The "Quiz" comes from teaching myself some basic Shell Scripting, and I wanted to master the "if" and so on. And the quiz seemed to have enough 'if' :)

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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