/* * Intro to Programming CSE 1310 * University of Texas at Arlington */ package code1feb18; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author jcmtiernan */ public class Code1Feb18 { /** * @param args the command line arguments */ public static void main(String[] args) { // Calculating values of coinage final int nickel = 5; final int dime = 10; final int penny = 1; final int quarter = 25; final int halfDollar = 50; final int dollar = 100; double couchMoney = 0.0; Scanner input = new Scanner(System.in); Logger.getGlobal().setLevel(Level.OFF);// Use Level.OFF to turn off int pennies = 0; // Use Level.INFO to see output int nickels = 0; int dimes = 0; int quarters = 0; int halfDollars = 0; int dollars = 0; String moreCoins = ""; Logger.getGlobal().info("Example program with coins\n"); System.out.println("Let's find out how much money is inside the couch (or in your pocket, etc.)"); System.out.print("How many pennies do you have? "); pennies = input.nextInt(); Logger.getGlobal().info("The user entered "+pennies+" pennies.\n"); System.out.print("\nHow many nickels do you have? "); nickels = input.nextInt(); Logger.getGlobal().info("The user entered "+nickels+" nickels.\n"); System.out.print("\nHow many dimes do you have? "); dimes = input.nextInt(); Logger.getGlobal().info("The user entered "+dimes+" dimes.\n"); System.out.print("\nHow many quarters do you have? "); quarters = input.nextInt(); Logger.getGlobal().info("The user entered "+quarters+" quarters.\n"); System.out.print("\nDo you have any other coins? Enter Y or N "); moreCoins = input.next(); if (moreCoins.equalsIgnoreCase("Y") ) { // check on halfdollars and dollar coins System.out.print("\nHow many halfDollars do you have? "); halfDollars = input.nextInt(); System.out.print("\nHow many dollars do you have? "); dollars = input.nextInt(); } // How do we calculate the amount of money in dollars? couchMoney = (nickel * nickels + penny * pennies + dime * dimes + quarter * quarters + halfDollar * halfDollars + dollar * dollars) / 100.0 ; //couchMoney = couchMoney/100; System.out.printf("\nYour total couch money is $%.2f. TA DA!\n\n",couchMoney); //System.out.println("Your total couch money is "+couchMoney+". TA DA!"); System.out.println("Is this enough money to buy lunch? Y / N "); // If user says yes, then print "Yay! Let's go eat!" // If the user says no, then ask the user if they have food at home for lunch. // If user says yes, then print "OK, let's make lunch!" // else, ask the user how much lunch will cost and [ask lunch cost] // then calculate how much more money they need to find in // the chair cushions // [This section will show nested if-else examples] // [choose lunch cost] Instead of asking the user how much lunch costs // let the user choose from a variety of lunch choices // Version A: number the choices // Version B: name the choices // [This section will use a switch] // Now we want to ask the user if they want run the whole program again // Set up control to allow program to run more than once. // [This will have us go back and put in a loop structure] } }