/* Example code from Sept 2 */ package sept2test; import java.util.Scanner; /** * * @author jcmtiernan */ public class Sept2Test { /** * @param args the command line arguments */ public static void main(String[] args) { // Test code Scanner input = new Scanner(System.in); int myValue; int secondValue; double floatingPointValue, secondFLValue; byte smallValue; boolean twoValue; int strLength; int strEO; String str1 = "This is CSE 1310 class on Tues 22 Sept 2015"; String str2 = new String(); String str3; String str4; int int4; double doub4; char yN = 'Y'; boolean whileCondition = true; /* while (whileCondition) { System.out.println(str1); System.out.println("**"+str2+"**"); System.out.print("Please enter a line of input that contains one integer and 1 double: "); str3 = input.next(); str4= input.next(); //str3 = str3.substring(5, 5); System.out.println("You entered string "+str3+" "+str4); int4 = Integer.parseInt(str3); doub4 = Double.parseDouble(str4); System.out.println("From the string *"+str3+ "* we parsed "+int4+" and we add 1 to get "+(int4 + 1)+ " and we added 1 to the string and got "+(str3+1) ); System.out.println("From the string *"+str4+ "* we parsed "+doub4+" and we add 1 to get "+(doub4 + 1)+ " and we added 1 to the string and got "+(str4+1) ); input.nextLine(); System.out.print("Would you like to enter another string to parse? Please enter Y or N: "); str3 = input.nextLine(); System.out.println("You entered **"+str3+"**"); yN = str3.charAt(0); if ((yN == 'n')|| (yN == 'N')) { whileCondition = false; System.out.println("Thank you for playing! "); } } */ int count = 1; double sum = 0; int k= 5; while (count <= 100000) { sum = sum + count; count = count +1; if ((count % 100) == 0) { System.out.println("Sum is "+sum); } //System.out.print("Would you like to continue? Please enter an integer value between 1 and 10 inclusive: "); //k = input.nextInt(); } System.out.println("Sum is "+sum+"in while loop"); sum = 0; for (count = 0 ; count <= 100000 ; count++ ) { sum = sum + count; } System.out.println("Sum is "+sum+"in for loop"); /* StrLength = str3.length(); System.out.println("THe string length is "+strLength); strEO = strLength % 2; // save 0 or 1 for even or odd if (strEO == 0) { System.out.println("THe length of the string is even"); } else if (strLength > 6) { System.out.println("THe length of the string is odd and longer than 6"); } else { System.out.println("THe length of the string is odd and shorter than 6"); } */ /* System.out.print("Please enter an integer: "); myValue = input.nextInt(); System.out.print("Now enter a" +"floating point number: "); floatingPointValue = input.nextDouble(); System.out.print("Please enter a byte value: "); smallValue = input.nextByte(); System.out.println("Now we compare "+myValue+" and "+floatingPointValue+" to get a boolean value: "); twoValue = (myValue != floatingPointValue); secondValue = 9; secondFLValue = secondValue/floatingPointValue; */ //System.out.println("Result of 9 / FLValue is: "+secondFLValue); //System.out.println("Y'all are awesome!"); //System.out.print("You are a perfect "); //System.out.println((6+4)/myValue); //System.out.println("The input values were "+myValue+" and "+floatingPointValue); //System.out.println("The byte and boolean are "+smallValue+" and "+twoValue); } }