Question
help me with UML Diagram, i am a bit lost the code as follows below //Java Code:- package billing; import java.io.File; import java.io.FileWriter; import java.util.ArrayList;
help me with UML Diagram, i am a bit lost the code as follows below
//Java Code:-
package billing;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class Change {
static ArrayList names=new ArrayList();
static ArrayList coins=new ArrayList();
public static boolean readData() {
File file=new File("C:Usersilesheclipse-workspaceChegginput.txt");
try {
Scanner sc=new Scanner(file);
while(sc.hasNextLine()) {
String s=sc.nextLine();
String sp[]=s.split(" ");
names.add(sp[0]);
coins.add(Integer.parseInt(sp[1]));
}
sc.close();
return true;
}catch(Exception e) {
return false;
}
}
public static int[] calculateChange(int amount) {
int a[]= {0,0,0,0};
while(amount>=50) {
a[0]++;
amount-=50;
}
while(amount>=20) {
a[1]++;
amount-=20;
}
while(amount>=10) {
a[2]++;
amount-=10;
}
while(amount>=5) {
a[3]++;
amount-=5;
}
return a;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
readData();
while(true) {
System.out.println("1.Enter Name:");
System.out.println("2.Exit");
int x=sc.nextInt();
if(x==2)
break;
sc.nextLine();
String name=sc.nextLine();
for(int i=0;i if(names.get(i).equals(name)) {
x=i;
}
}
int z[]=calculateChange(coins.get(x));
String output=name+","+z[0]+","+z[1]+","+z[2]+","+z[3]+"";
System.out.print(output);
try {
File f=new File("C:Usersilesheclipse-workspaceFirstsrcgrades.csv");
FileWriter fw=new FileWriter(f,true);
fw.write(output);
fw.close();
}catch(Exception e) {
}
}
sc.close();
}
}
Please help me with UML Diagram, i am a bit lost
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To create a UML class diagram for the Change class we need to represent its attributes methods and r...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started