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

Java program. The Spacely Sprocket company has expanded operations and is now pr

ID: 666592 • Letter: J

Question

Java program. The Spacely Sprocket company has expanded operations and is now producing 50 different kinds of sprockets. The different sprockets are numbered 1 though 50. During the month of November, orders have been taken for the different sprockets. The following input file contains records where each record contains a sprocket number (1-50) followed by the quantity ordered: November Orders.txt (this will be at the bottom)

Using the above input file of orders, rewrite the Spacely Sprocket program to produce a summary report for all 50 sprockets produced. Rather than using 50 separate accumulator variables, you must use a single array to represent the 50 different accumulators. Use the array and loops in your program to summarize the orders and output the report. Don't forget to initialize each of the array locations to 0 (because they are accumulators). For full credit, be sure to display the report in a Scrolling Pane in a Window.

November_Orders.txt (below)

Explanation / Answer

A frame, implemented as an instance of the JFrame class, is a window that has decorations such as a border, a title, and supports button components that close or iconify the window. Applications with a GUI usually include at least one frame.

import java.io.*;
import javax.swing.*;

class FrameEx extends Frame{
   FrameEx(){
    JFrame jf = new JFrame();    
    JTextArea jta = new JTextArea();
    JScrollPane jsp= new JScrollPane(jta);

    jf.setSize(400,400);
     jf.setExtendedState(JFrame.MAXIMIZED_BOTH);
     jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     jf.add(jsp);
    jf.setVisible(true);
   }
    int snum, quantity, z=0;
    InputFile reportFile;
    reportFile = new InputFile("C:DesktopNovember Orders.txt"); // givethe path ofthe file

    while (!reportFile.eof()){

        snum = reportFile.readInt();
        quantity = reportFile.readInt();

        total[snum-1] = total[snum-1] + quantity;

    }
    for (int i=0;i<50; ){
        jta.append((i+1) + "     " + total[i] + " ");
        i++;
    }
public static void main(String args[]){
FrameEx fe = new FrameEx();
fe.FrameEx();// calls the constructor
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote