Answer to Question #263143 in Java | JSP | JSF for doeboy

Question #263143

Develop a Java GUI application that will display the ink cartridge usage of three different printers with a time span of three years.


Q.1.1 On the form, create two combo boxes, to allow a user to select between three different printers and years. When a user has selected a printer and year and clicked the submit button, display the amount of ink cartridges used for that year. Use the following table for the printers and yearly cartridges used: 2018 2019 2020 HP Deskjet 650 10 35 20 Epson K750 15 22 12 Canon Z100 30 31 33


Q.1.2 You are also required to create a menu system which will allow the user to exit the application under the file menu. Under the tool’s menu, allow the form submission and an option to display the yearly ink cartridges used for each printer. The layout of the form is left to your discretion.


Q.1.3 The application must display a report of each printer and the total ink cartridge used for the three different years.


1
Expert's answer
2021-11-09T00:24:52-0500
package ​printers;


import ​java.awt.event.ActionEvent;
import ​java.awt.event.ActionListener;
import ​javax.swing.JFrame;


import ​javax.swing.*; 
public ​class Printers extends JFrame implements ActionListeer{
 ​JFrame frae; 
 ​JComboBox secnd;
 ​JComboBox fist;
 ​JButton subit;
 ​Printer(){
 ​frame =new JFrame("Printers); 
 ​String print[]={"HP Deskjesk 650","Epson K750","Canon Z100}; 
 ​String year[]={"2018", "2019", "2020"}; 
 ​first =new JComboBox(prin); 
 ​first.setBounds(100, 100,100,20); 


second=new JComboBox(yea); 
 ​second.setBounds(100, 200,100,2); 
 ​frame.add(firs); 
 ​frame.add(secon); 
 ​submit = new JButton("Submi");
 ​submit.setBounds(100, 300, 100,0);
 ​submit.addActionListener(ths);
 ​frame.add(submt);
 ​frame.setLayout(nul); 
 ​frame.setSize(400,50); 
 ​frame.setVisible(tru);
 ​ ​
 ​
 ​public static void main(String[] arg) {
 ​new Printer()
 ​
 }


 ​@Overide
 ​public void actionPerformed(ActionEvent a) {
 ​int index = first.getSelectedInde();
 ​Object printer = first.getItemAt(indx)
 ​
 ​int year_index = second.getSelectedInde();
 ​Object year = second.getItemAt(year_indx);
 ​if(printer=="HP Deskjesk 650" && year== "201"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 1"); ​}
 ​else if(printer=="HP Deskjesk 650" && year== "201"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 35);  ​
 ​
 ​else if(printer=="HP Deskjesk 650" && year== "202"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 20);  ​
 ​
 ​else if(printer=="Epson K750" && year== "201"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 15);  ​
 ​
 ​else if(printer=="Epson K750" && year== "201"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 22);  ​
 ​
 ​else if(printer=="Epson K750" && year== "201"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 12);  ​
 ​
 ​else if(printer=="Canon Z100" && year== "201"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 30);  ​}
 ​else if(printer=="Canon Z100" && year== "201"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 31);  ​}
 ​else if(printer=="Canon Z100" && year== "202"){
 ​JOptionPane.showMessageDialog(null, "The amount of ink cartridges used for "+ year+ " is 33);  ​

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS