Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how do i code this in Java Method createlnvoice generates a String that is event

ID: 3884926 • Letter: H

Question


how do i code this in Java

Method createlnvoice generates a String that is eventually printed in a JOptionPane dialog box. createlnvoice calls calculateCharge. If the customer is type STUDENT, the base cost is $25. If the customer is type FACULTY, the base cost is $50. If the customer is type GOVERNMENT, the base cost is $35. calculateCharge charges $99 if the course type is PROGRAMMING or MATHEMATICS; $59 if the course type is PHOTOGRAPHY, MUSIC, or PAINTING; $39 if the course type is MISC. If the customer is type STUDENT each online course is an additional $20. If the customer type is FACULTY each online course is an additional $25 and each in class course is an additional $5. If the customer type is GOVERNMENT, there is no extra charge. ArrayList courseList keeps a list of all courses taken/enrolled in by the customer. Write test case, CustomerTest, that creates three customers with the data given. The customers are kept in ArrayList, customerList. Then, using an enhanced for loop, polymorphically walk through the customerList and create the invoice for each customer. Print all customer information to the command prompt. Print the customer name, customer account number and total charges for each customer in a dialog box. All customers will show in one dialog box as shown. Adhere to Java coding standards as posted on Blackboard.

Explanation / Answer

import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.TimerTask; public class ImageGallery extends JFrame { private ImageIcon myImage1 = new ImageIcon ("Chrysanthemum.jpg"); private ImageIcon myImage2 = new ImageIcon ("Desert.jpg"); private ImageIcon myImage3 = new ImageIcon ("Jellyfish.jpg"); private ImageIcon myImage4 = new ImageIcon ("Penguins.jpg"); JPanel ImageGallery = new JPanel(); private ImageIcon[] myImages = new ImageIcon[4]; private int curImageIndex=0; public ImageGallery () { ImageGallery.add(new JLabel (myImage1)); myImages[0]=myImage1; myImages[1]=myImage2; myImages[2]=myImage3; myImages[3]=myImage4; add(ImageGallery, BorderLayout.NORTH); JButton PREVIOUS = new JButton ("Previous"); JButton PLAY = new JButton ("Play"); JButton STOP = new JButton ("Stop"); JButton NEXT = new JButton ("Next"); JPanel Menu = new JPanel(); Menu.setLayout(new GridLayout(1,4)); Menu.add(PREVIOUS); Menu.add(PLAY); Menu.add(STOP); Menu.add(NEXT); add(Menu, BorderLayout.SOUTH); //register listener PreviousButtonListener PreviousButton = new PreviousButtonListener (); PlayButtonListener PlayButton = new PlayButtonListener (); StopButtonListener StopButton = new StopButtonListener (); NextButtonListener NextButton = new NextButtonListener (); //add listeners to corresponding componenets PREVIOUS.addActionListener(PreviousButton); PLAY.addActionListener(PlayButton); STOP.addActionListener(StopButton); NEXT.addActionListener(NextButton); } public static void main (String [] args) { ImageGallery frame = new ImageGallery(); frame.setSize(490,430); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); } class PreviousButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { if(curImageIndex>0 && curImageIndex =0 && curImageIndex < 3) { ImageGallery.remove(0); curImageIndex = curImageIndex + 1; ImageIcon TheImage= myImages[curImageIndex]; ImageGallery.add(new JLabel (TheImage)); ImageGallery.validate(); ImageGallery.repaint(); } else { ImageGallery.remove(0); ImageGallery.add(new JLabel (myImage4)); curImageIndex=3; ImageGallery.validate(); ImageGallery.repaint(); } } } }