Info1103 Assignment Submission

package assignment; //INFO1103 Assignment 3, 19/04/2015 import java.util.Arrays; import java.util.Scanner; //import the scanner API import java.text.DecimalFormat; //import the decimal formatting API public class CoffeeBot { //superclass public static void main(String args[]){ //main method checkArgs(args); String name = greet(); int total = order(args,name); double difference = payment(total); //runInput(); //2 3 test input change(difference,name); System.out.println("Thank you, "+ name + "."); System.out.println("See you next time."); //System.out.println("The change needed is " + difference); System.out.println("Reached program termination. .."); } public static void checkArgs(String[] args){ if(args.length == 2){ <= 0){ System.out.println("Negative supply chain. System terminating."); System.exit(0); }else if(Integer.parseInt(args[0]) <=0){ System.out.println("Negative supply of coffee Integer.parseInt(args[0]). System terminating."); System.exit(0); }else if(Integer.parseInt(args[1]) <=0){ System.out.println("Negative supply of coffee Integer.parseInt(args[1]). System terminating."); System.exit(0); } } else if(args.length == 1){ System.out.println("Not enough arguments. System terminating."); System.exit(0); } else if(args.length > 2){ System.out.println("Too many arguments. System terminating."); System.exit(0); } else if(args.length == 0){ System.out.println("No arguments. System terminating."); System.exit(0); } } public static String greet(){ System.out.print("Hello, what's your name? "); Scanner inputName = new Scanner(System.in); //start up the keyboard scanner //String name = inputName.next(); String name = inputName.next(); do{ System.out.print("Would you like to order some coffee, " + name + "? (y/n) "); String status = inputName.next(); if(status.equals("y")){

/*** info1103 - assignment 1* staff**/import java.util.Scanner;public class CoffeeBot {public static void main(String[] args) {String name;String response;Scanner scan = new Scanner(System.in);// Parse command line argumentsif (args.length == 0) {System.out.printf("No arguments. System terminating.\n");return;} else if (args.length == 1) {System.out.printf("Not enough arguments. System terminating.\n");return;} else if (args.length > 2) {System.out.printf("Too many arguments. System terminating.\n");return;}// Set pricesdouble cupPrice = 2.00;double shotPrice = 1.00;// Set amount of suppliesint cupSupply = Integer.parseInt(args[0]);int shotSupply = Integer.parseInt(args[1]);if (cupSupply < 0 && shotSupply < 0) {System.out.printf("Negative supply chain. System terminating.\n");return;} else if (cupSupply < 0) {System.out.printf("Negative supply of coffee cups. System terminating.\n");return;} else if (shotSupply < 0) {System.out.printf("Negative supply of coffee shots. System terminating.\n");return;}// Greet the customerSystem.out.printf("Hello, what's your name? ");name = scan.nextLine();// Check whether to proceed with an orderwhile (true) {System.out.printf("Would you like to order some coffee, %s?

0 thoughts on “Info1103 Assignment Submission

Leave a Reply

Your email address will not be published. Required fields are marked *