/* * 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 spr17jan31; import java.util.Scanner; /** * * @author jcmtiernan */ public class Spr17Jan31 { /** * @param args the command line arguments */ public static void main(String[] args) { int hVal = 1; double wVal = 1.76583; int dVal; String name; String answer; Scanner input = new Scanner(System.in); //System.out.println("1st program"); //System.out.printf("%1dst program\n",hVal); //System.out.printf("%.3fst program\n",wVal); // Volume is a three dimensional measure // a cubic foot has a volume of 12"*12"*12" = 1728 cubic inches /* System.out.print("Please enter your first name: "); name = input.next(); System.out.println(); System.out.print("Please enter a number of cm as an integer: "); hVal = input.nextInt(); System.out.println(); System.out.print("Please enter a floating point number: "); wVal = input.nextDouble(); System.out.println(); System.out.print("Please enter an integer: "); dVal = input.nextInt(); System.out.println(); // formatted output System.out.printf("%s, you entered height %d, ", name, hVal); System.out.printf("width %.2f, and depth %d\n", wVal, dVal); // Error check for invalid data using a boolean flag boolean validData = true; // First check height if (hVal<= 0) { validData = false; } else if (wVal <= 0) // Then width { validData = false; } else if (dVal <= 0) // Then depth { validData = false; } System.out.println(); // if everything is good, then print inches output with volume in a table // then print meters output with volume in the next line of the table if (validData) { System.out.printf("%-10s%10s%10s%10s%10s%10b\n","Units", "Ht","Width","Depth","Vol",validData); System.out.printf("%-10s%10d%10.2f%10d%10.2f\n","Cm", hVal, wVal, dVal, (hVal*wVal*dVal)); System.out.printf("%-10s%10.4f%10.4f%10.4f%10.7f\n", "M", (hVal/100.0), (wVal/100), (dVal/100.0), (hVal*wVal*dVal/1000000)); } else { System.out.println("Invalid values were entered in input data. All values must be positive."); } */ // Now assume that the three values you entered before are the // three sides of a triangle. System.out.print("Now assume that the three values you entered before "); System.out.println("are the three sides of a triangle."); System.out.print("Would your triangle have any obtuse angles? (yes or no) "); answer = input.next(); // compare answer to words "yes" and "no" if (answer.equalsIgnoreCase("yes")) { System.out.println("You are obtuse. You entered "+answer); } else if (answer.equals("no")) { System.out.println("You are very (a)cute. You entered "+answer); } else { System.out.println("You are confused. You entered "+answer); } /* System.out.println("Please enter three more one or two digit values for "); System.out.println("height, width, and depth. Enter in the form of "); */ } }