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

Write a program that will read some students marks (floating-point numbers) from

ID: 3824498 • Letter: W

Question

Write a program that will read some students marks (floating-point numbers) from a file and display the average of these marks on the console. The first line of the file will contain an integer number representing the number of marks in the file. Write a method that will throws "IOException" and "InvalidFormatException". The method will take a Scanner object as parameter and return number of non-empty lines read from the scanner obj. If a line contains an invalid integer number, then it should throw an "InvalidFormatException", whereas if there is any empty line in the file it should throw "IOException" Write the main method that will open a file and create a scanner object associated with the file, and then calls the method (created in the earlier question). In other words, show how the above method can be called in the main method (you need to handle the thrown exceptions in the main). Write a GUI program that will show a textfiled and a button on the frame. The caption of the button should be "Click Me!". Create a Person class with age, lastName, firstName and salary attributes. The person class should also implement Comparable interface and provide a definition for "compareTo" method to compare persons based on their age. In other words, make sure that the following code prints persons according to their increasing age value:

Explanation / Answer

import java.awt.*;
import javax.swing.*;

class Button extends JFrame
{
JButton bChange ; // reference to the button object

// constructor for Button
Button(String title)
{
super( title ); // invoke the JFrame constructor
setLayout( new FlowLayout() ); // set the layout manager

bChange = new JButton("Click Me!"); // construct a JButton
add( bChange ); // add the button to the JFrame
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );   
}
}

public class ButtonDemo
{
public static void main ( String[] args )
{
Button btn = new Button("Button");

btn.setSize( 150, 75 );   
btn.setVisible( true );   
}
}

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