Example2_18

Example2_18 - + ", ch = " + ch + ", z =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; i public class Example2_18 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int firstNum; int secondNum; char ch; double z; firstNum = 4; //Line 1 System.out.println("Line 2: firstNum = " + firstNum); //Line 2 secondNum = 2 * firstNum + 6; //Line 3 System.out.println("Line 4: firstNum = " + firstNum + ", secondNum = " + secondNum); //Line 4 z = (firstNum + 1) / 2.0; //Line 5 System.out.println("Line 6: firstNum = " + firstNum + ", secondNum = " + secondNum + ", z = " + z); //Line 6 ch = 'A'; //Line 7 System.out.println("Line 8: firstNum = " + firstNum + ", secondNum = " + secondNum + ", ch = " + ch + ", z = " + z); //Line 8 secondNum = console.nextInt(); //Line 9 System.out.println("Line 10: firstNum = " + firstNum + ", secondNum = " + secondNum + ", ch = " + ch + ", z = " + z); //Line 10 z = console.nextDouble(); //Line 11 System.out.println("Line 12: firstNum = " + firstNum + ", secondNum = " + secondNum
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: + ", ch = " + ch + ", z = " + z); //Line 12 firstNum = 2 * secondNum + (int)(z); //Line 13 System.out.println("Line 14: firstNum = " + firstNum + ", secondNum = " + secondNum + ", ch = " + ch + ", z = " + z); //Line 14 secondNum = secondNum + 1; //Line 15 System.out.println("Line 16: firstNum = " + firstNum + ", secondNum = " + secondNum + ", ch = " + ch + ", z = " + z); //Line 16 ch = console.next().charAt(0); //Line 17 System.out.println("Line 18: firstNum = " + firstNum + ", secondNum = " + secondNum + ", ch = " + ch + ", z = " + z); //Line 18 firstNum = firstNum + (int)(ch); //Line 19 System.out.println("Line 20: firstNum = " + firstNum + ", secondNum = " + secondNum + ", ch = " + ch + ", z = " + z); //Line 20 z = firstNum - z; //Line 21 System.out.println("Line 22: firstNum = " + firstNum + ", secondNum = " + secondNum + ", ch = " + ch + ", z = " + z); //Line 22 } }...
View Full Document

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Page1 / 2

Example2_18 - + ", ch = " + ch + ", z =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online