/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package firstfall16; import java.util.Scanner; /** * * @author jcmtiernan */ public class FirstFall16 { /** * @param args the command line arguments */ public static void main(String[] args) { // First program on first day of class int banana = 0; // declaration with initialization of 0 int apple = 5; double pie = 0; Scanner input = new Scanner(System.in); String teststr = new String("howdy doody!"); /* System.out.println("Hello world"); System.out.println("Value is " + 5 +" an integer"); System.out.println(banana); System.out.println(pie); System.out.println(banana + pie); */ banana = 11; // assignment pie = 10.5; double bpie = banana+pie; System.out.println("banana value = " + banana + " " + teststr); int strlength = teststr.length(); System.out.println("String length is "+strlength); //System.out.println(banana); //System.out.println(pie); //System.out.println(bpie); double dessert = (double) banana / apple; System.out.println("dessert is "+dessert); // Showing examples of using the scanner /* System.out.print("Enter two double values and one integer value for dessert, pie and fruit: "); dessert = input.nextDouble(); pie = input.nextDouble(); int fruit = input.nextInt(); System.out.println("New dessert is "+dessert +" and pie is " + pie + " fruit is "+ fruit ); */ System.out.print("Enter a word then "); System.out.println(" Enter two double values and one integer value for dessert, pie and fruit: "); teststr = input.next(); System.out.println("You entered *"+teststr+"*"); dessert = input.nextDouble(); pie = input.nextDouble(); int fruit = input.nextInt(); System.out.println("New dessert is "+dessert +" and pie is " + pie + " fruit is "+ fruit ); input.nextLine(); // to ignore any other input on the line System.out.print("Enter a string: "); teststr = input.nextLine(); System.out.println("You entered *"+teststr+"*"); int pudding = (banana / apple); int sweet = banana % apple; //System.out.println("pudding is "+pudding+" and sweet is "+sweet); dessert = Math.pow(pie, 2); //System.out.println("dessert is "+dessert); //System.out.println("printing sum of banana and pie "+ (bpie)); } }