Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Taxation Of Individuals And Business Entities 2015

Authors: Brian Spilker, Benjamin Ayers, John Robinson, Edmund Outslay, Ronald Worsham, John Barrick, Connie Weaver

6th Edition

978-1259206955, 1259206955, 77862368, 978-0077862367

More Books

Students also viewed these Programming questions

Question

26. How do genes and hormones infl uence taste sensitivity?

Answered: 1 week ago

Question

28. What is the mean life span of an olfactory receptor?

Answered: 1 week ago