package abc.ui;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.Random;
public class MagicMatrix extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JPanel chartPanel;
private JTextField termField;
double a;
private static DecimalFormat df2 = new DecimalFormat("#.##");
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MagicMatrix frame = new MagicMatrix();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MagicMatrix() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200, 200, 450, 450);
//Set the layout ato grid layout and set the size of the layout to 10 * 10 matrix
setLayout(new GridLayout(10,10));
//Random class to get the random value from a upper bound range given
Random random =new Random();
//Iterate to create 100 cells for the 10*10 matrix
JTextField field;
for(int i=0;i<100;i++) {
field =new JTextField(1);
field.setText(Integer.toString(random.nextInt(2)));
add(field);
}
setSize(300,300);
}
}

(Programming Exercises from text, Q14.7) (Display random 0 or 1) Write a program that displays a...
Part I: Code writing: 1. 3pts (Display matrix of numbers) Write a function that displays an n-by-n matrix using the following header: void printMatrix(int n) Each element is between (3,9), which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix. Here is a sample run: Enter n: 2 47 96
Java Programming Reading from a Text File
Write a Java program that will use an object of the Scanner class to read employee payroll data from a text file The Text file payroll.dat has the following: 100 Washington Marx Jung Darwin George 40 200 300 400 Kar Car Charles 50 22.532 15 30 The order of the data and its types stored in the file are as follows: Data EmployeelD Last name FirstName HoursWorked double HourlyRate Data Tvpe String String...
Programming Language is Java Lab 1: Programming Exercises Input/Process/Output 1) Run the Numbers. Write a program with two input values. The program should display the sum, difference, quotient, product, and average of the two numbers. 2) Jake’s Problem. Jake has a car with an 8-gallon fuel tank. Jake fills his tank with gas and drives 60 miles to a friend’s house. When he gets to his friend’s house, he has 6 gallons left in his fuel tank. Write a program...
Write a program that reads a matrix from the keyboard and displays the summations of all its rows on the screen. The size of matrix (i.e. the number of rows and columns) as well as its elements are read from the keyboard. A sample execution of this program is illustrated below: Enter the number of rows of the matrix: 3 Enter the number of columns of the matrix: 4 Enter the element at row 1 and chd umn 1: 1...
In NI LabVIEW please, Construct a VI that displays a random number between 0 and 1 once every second. Also, compute and display the average of the last four random numbers generated. Display the average only after four numbers have been generated; otherwise display a 0. Each time the random number exceeds 0.5, generate a beep sound using the Beep.vi.
Please go to the Practice Exercises (at the end of Chapter 3 in your text on page 129) and do Exercise E 3.14 which asks you to compute and print the current season of the year depending on the month and day (input as integers). Be sure to review Java boolean operators, multi-way IF-ELSE statements, Switch statements, and String comparison methods before implementing your Java code. The algorithm for this program has been written for you and is included in...
Intro to Programming and Logic (chapter 5): Python 2 - Conditionals and Recursion: Write a program that will simulate a roulette wheel. The pockets on a roulette wheel are different colors. There are 36 pockets – numbered 0 to 35. Pocket 0 and 18 are green. For pockets 1 – 8, the even numbers are black and the odd numbers are red. For pockets 9 – 17, the even numbers are red and the odd numbers are black. For pockets...
java programming Problem 2 (25 points) Counting Character Frequency. Write a program to analyze a text file (a novel or a report, or just a sequence of letters or symbols), by reading the file into a byte array, convert to a string, and then scan the string letter by letter to count the frequencies of all unique characters in the text, after that, the letters with frequencies greater than 0 and the frequencies are reported side by side. All members...
JAVA:
(15 marks) Write a program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. "Out of Bounds") and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle...
1. (30 Points) Write a MATLAB program that displays "The multiplication of 10 multiplied by integers of 1 through 15. Display your result back to the user with 2 decimal places (yes, 2 decimal places). You must implement your code using a for loop. The result should have the following format: The multiplication of 10*1 =10.00 The multiplication of 10*2 =20.00 The multiplication of 10'3=30.00 The multiplication of 10*15=150.00 2. (35 Points) Write MATLAB code to prompt a user for...