User:Mlzg4
From Wikipedia, the free encyclopedia
Yeah, it's me.
// Program: prog3_2.java // Programmer: Michael Graczyk // Description: This program uses methods of the Util class to display the value of a variable as five, then calculates the function of x using the Math class, then displays a formatted output of the function, then a formatted output of the solution. // Date:11/05/06 // Methods: main import java.io.*; import java.util.*; import javax.swing.*; import java.text.*;
public class prog3_2 {
public static void main(String args[]) { Customer first_customer = new Customer();
do { first_customer.main_menu(); } while (first_customer.quit_menu == false);
Util.heading("Michael Graczyk","prog3_02","11-23-11"); Util.skip(3); System.out.println(first_customer.Calls); }
public static String money_return(Double monies) {
NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); double twoD = Math.round(monies*100)/100f; String formatted = nf.format(twoD); return formatted; }
public static void wait(int seconds) // It's static because it has nothing to do with the object.
{ long t0, t1; t0 = System.currentTimeMillis()+seconds*1000; // You have got to show me a more efficient way to do this. This is almost retarted do { t1 = System.currentTimeMillis(); } while (t1<t0); }
}
/**************************Customer class************************************************/
class Customer extends Util { static final double basic_rate_fee = 15.95, price_per_minute = .20, federal_tax = .0298, //These are numbers in decimals, not percentages! state_local_tax = .082;
String customer_name, Calls;
int menu_selection, callnum = 0;
boolean quit_menu = false;
double basic_fee, call_time_mins, Long_distance_calls_fee;
InputStreamReader input = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(input);
Customer() { try { System.out.println("What is the customer's name?\n"); customer_name = reader.readLine(); } catch(Throwable t) { System.out.println("WTF"); } }
public void main_menu() { int selection = 0; Util.skip(2);
System.out.println("What would you like to do, "+customer_name+"?\n(Press the number that corresponds with your menu selection.)\n"); System.out.println("\n1: Make long distance call. (please make three of these)"); System.out.println("2: Argue with your sales representitive."); System.out.println("3: Quit and print your reciept");
try { selection = Integer.parseInt(reader.readLine()); } catch(Throwable t) { System.out.println("Please don't screw with me"); main_menu(); }
if (selection == 1) { make_call(); }
if (selection == 2) { argue(); }
if (selection == 3) { escape(); }
}
private void make_call() { try{ callnum++; System.out.println("How many minutes will your call be?"); call_time_mins += Double.parseDouble(reader.readLine()); System.out.println("\nHow many seconds will your call be?"); call_time_mins += (Double.parseDouble(reader.readLine()))/60f*100; Calls += " "+"Call "+callnum+":\t\t\t";
} catch (Throwable t){} }
private void argue() { try { System.out.println("Fine, but now your outta here!"); System.exit(1); } catch (Throwable t){} } private void escape() { quit_menu = true; }
}