JAVA. Create a UML class diagram for the following class/driver:
PhoneCaseSaleApp.java :
import java.util.Scanner;
public class PhoneCaseSaleApp
{
public static void main(String args[])
{
int blue_count = 0,
black_count = 0, rainbow_count = 0, tie_dye_count = 0,
floral_delight_count = 0;
int
hard_count,gel_count;
float hard_cost,
gel_cost;
float hard_profit,
gel_profit;
float total_cost;
float
total_profit;
Scanner in = new
Scanner(System.in);
System.out.println("How
many Blue Hard Cases to Order");
blue_count=in.nextInt();
System.out.println("How
many Black Hard Cases to Order");
black_count=in.nextInt();
System.out.println("How
many Rainbow Gel Cases to Order");
rainbow_count=in.nextInt();
System.out.println("How
many Tie Dye gel Cases to Order");
tie_dye_count=in.nextInt();
System.out.println("How
many FLoral Delight gel Cases to Order");
floral_delight_count=in.nextInt();
hard_count =
blue_count+black_count;
System.out.println("Total Hard Cases Sold = " +hard_count);
gel_count =
rainbow_count+tie_dye_count+floral_delight_count;
System.out.println("Total Gel Cases Sold = " +gel_count);
HardCaseSale h = new
HardCaseSale(blue_count,black_count);
GelCaseSale g = new
GelCaseSale(rainbow_count, tie_dye_count,
floral_delight_count);
System.out.println("Order Summary");
System.out.println();
System.out.println();
h.toString();
System.out.println();
System.out.println();
g.toString();
System.out.println();
System.out.println();
hard_cost =
h.calculateHardCaseCost();
gel_cost =
g.calculateGelCaseCost();
hard_profit =
calculateHardCaseScoutProfit(hard_count, hard_cost);
gel_profit =
calculateGelCaseScoutProfit(gel_count, gel_cost);
System.out.println("Profit from Hard Cases=
"+hard_profit);
System.out.println("Profit from Gel Cases=
"+gel_profit);
total_cost = hard_cost +
gel_cost;
total_profit =
hard_profit + gel_profit;
calculateTotalNetCost(total_cost, total_profit);
}
public static float
calculateHardCaseScoutProfit(int count, float cost)
{
float r;
float p;
if(count > 9)
r = 12.0f;
else
r = 7.0f;
p = cost*(r/100);
return p;
}
public static float
calculateGelCaseScoutProfit(int count, float cost)
{
float r;
float p;
if(count > 7)
r = 12.0f;
else
r = 7.0f;
p = cost*(r/100);
return p;
}
public static void calculateTotalNetCost(float
total_cost, float total_profit)
{
float netCost =
total_cost - total_profit;
System.out.println("Total Net Cost = "+netCost);
}
}
JAVA. Create a UML class diagram for the following class/driver: PhoneCaseSaleApp.java : import java.util.Scanner; public class...
import java.util.Scanner; public class Chpt7_Project { public static void bubbleSort(int[] list) { int temp; for (int i = list.length - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (list[j] > list[j + 1]) { temp = list[j]; list[j] = list[j + 1]; list[j + 1] = temp; } } } ...
I cannot get this to work in IntelliJ import java.util.Scanner; public class Fibonacci { public static int fibonacci(int n) { if (n <= 1) return n; return fibonacci(n - 1) + fibonacci(n - 2); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); System.out.println(fibonacci(n)); in.close(); } }
Need help with the UML for this code? Thank you. import java.util.Scanner; public class Assignment1Duong1895 { public static void header() { System.out.println("\tWelcome to St. Joseph's College"); } public static void main(String[] args) { Scanner input = new Scanner(System.in); int d; header(); System.out.println("Enter number of items to process"); d = input.nextInt(); ...
Make a FLOWCHART for the following JAVA Prime Number Guessing Game. import java.util.Random; import java.util.Scanner; public class Project2 { //Creating an random class object static Random r = new Random(); public static void main(String[] args) { char compAns,userAns,ans; int cntUser=0,cntComp=0; /* * Creating an Scanner class object which is used to get the inputs * entered by the user */ Scanner sc = new Scanner(System.in); System.out.println("*************************************"); System.out.println("Prime Number Guessing Game"); System.out.println("Y = Yes , N = No...
Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); final int maxSize = 128; String[] titles = new String[maxSize]; int[] lengths = new int[maxSize]; int numDVDs = 0; String op; op = menu(stdIn); System.out.println(); while (!op.equalsIgnoreCase("q")) { if (op.equalsIgnoreCase("a")) { if (numDVDs < maxSize) numDVDs = addDVD(titles, lengths, numDVDs, stdIn); } else if (op.equalsIgnoreCase("t")) searchByTitle(titles, lengths, numDVDs, stdIn); else if (op.equalsIgnoreCase("l")) searchByLength(titles, lengths, numDVDs, stdIn); System.out.println('\n');...
Consider the following sample program: import java.util.Scanner; public class Palindrome { public static void main(String[] args){ Scanner kb = new Scanner(System.in); System.out.println("Enter a word:"); String word = kb.next(); String reverse = ""; for (int i=word.length()-1; i>=0; i--) reverse += word.charAt(i); boolean result = reverse.equalsIgnoreCase(word); if (result) System.out.println("The word " +word+ " is a Palindrome."); else System.out.println("The word " +word+ " is not a Palindrome."); } } Rewrite the program so that the main method is: public static void...
import java.util.Scanner; public class TriangleMaker { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Welcome to the Triangle Maker! Enter the size of the triangle."); Scanner keyboard = new Scanner(System.in); int size = keyboard.nextInt(); for (int i = 1; i <= size; i++) { for (int j = 0; j < i; j++) { System.out.print("*"); } System.out.println(); } for (int...
package cards; import java.util.ArrayList; import java.util.Scanner; public class GamePlay { static int counter = 0; private static int cardNumber[] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; private static char suitName[] = { 'c', 'd', 'h', 's' }; public static void main(String[] args) throws CardException, DeckException, HandException { Scanner kb = new Scanner(System.in); System.out.println("How many Players? "); int numHands = kb.nextInt(); int cards = 0; if (numHands > 0) { cards = 52 / numHands; System.out.println("Each player gets " + cards + " cards\n"); } else...
Can you help me with this code in Java??? import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int rows = 3; int columns = 4; int[][] arr = new int[rows][columns]; for(int i = 0; i < rows; ++i) { for(int j = 0; j < columns; ++j) { System.out.println("Enter a value: "); arr[i][j] = scan.nextInt(); } } System.out.println("The entered matrix:"); for(int i = 0; i < rows; ++i) { for(int j...
Please Refactor this Assignment by using Arraylist instead of Array. import java.util.Scanner; public class DaysOfWeeks { public static void main(String[] args) { String DAY_OF_WEEKS[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; char ch; int n; Scanner scanner = new Scanner(System.in); do { System.out.print("Enter the day of the Week: "); n = scanner.nextInt() - 1; if (n >= 0 && n <= 6) System.out.println("The day of the week is " + DAY_OF_WEEKS[n] + "."); else System.out.println("Invalid Entry"); System.out.print("Try again (Y/N): "); ch = scanner.next().charAt(0); }while(ch=='Y'); }...