PrintProgram 1

Write a complete Java program in a class named “PrintProgram” whose output is the text that would be the source code of a Java program named Hello that prints “Hello, world!” As its output.


StudentGrade 3

Write a program to calculate students average test scores and their grades. You may assume to following data:

Johnson 85 83 77 91 76
Aniston 80 90 95 93 48
Cooper 78 81 11 90 73
Gupta 92 83 30 69 87
Blair 60 83 77 91 76
Clark 60 85 45 39 67
Kennedy 77 31 52 74 83
Bronson 93 94 89 77 97
Sunny 79 85 28 93 82
Smith 85 72 49 75 63

Use three arrays: a one-dimensional array to store the student names, a (parallel) two-dimensional array to store the test score, and parallel one-dimensional array to store the grades. Your program must contain at least the following methods:
a method to read and store data into two arrays, a method to calculate the average test score and grade and a method to output the results. Have your program also output the class average.
Grade calculation to be computed as follows:

Marks Grades
85-100 A
75-84 B
65-74 C
50-64 D
<50 F


Screenshot 1-3

A young entrepreneur has decided to start an online exotic car sales company named Exotic Moves and he’s contacted you to build the company’s website. You have been given the following requirements and will need to create a prototype with JavaFX:
1. The company sells 5 brands of exotic cars (Aston Martin, Ferrari, Lamborghini, McLaren, and Maserati).
2. The website should allow a user to see the total inventory of cars or filter their view based on certain criteria.
3. The website must allow the user to filter cars by brand, color, prince range, or whether the car is convertible or not. The filters should work together (i.e. a user should be able to view all blue convertibles or all white Ferraris).
4. A user should be allowed to click on an image and view details about a specific car. Clicking on a car image should allow the user to see a larger view of the image along with details about the car.
5. Each car should display the following details:
Convertible (yes or no)
Number of cylinders
Time it takes to go from zero to 60 MPH
6. Along with the details, a user should be given the option to purchase (via a button) an individual car once an image of the car is clicked.
7. If a user chooses to purchase a car, the website should show a form asking for the user’s first and last name, credit number, credit card expiration date, and credit card 3 digit code. Once the information is entered, the website should display a receipt.
Additional Information
Your controls should enforce data validation. First and last names can only consist of letters A-Z. Credit card numbers should only consist of numbers and must be exactly 16 digits. The credit card date field must allow only dates. The credit card 3 digit code must allow only 3 numbers.
Your application window should be large enough to comfortably house all controls. Image size must be uniform across the board. There should be 2 viewing sizes – one for viewing as a collection and one for viewing individual images. When implementing the filtering feature, your app should present options to the user (for example, a combo box, a list, or a checkbox, control).
Follow good UI design practices. Your presentation should look and feel professional. Pay attention to spacing between controls.
Object Orientation
Your program should showcase your knowledge of polymorphism, inheritance, and encapsulation. Use accessor/mutator methods. Demonstrate a knowledge of either abstract classes or interfaces as a super class(es).

CIS 357 Assignment 1

Screenshot 1-1

CIS 357 Assignment 1

Refer to problem 8.19 in page 314 – 315. Name your program to

In addition to the given problem in the textbook, you want to provide the following additional methods:

public static int[][] generate2DArray(int row, int col)
public static void minimumConsecutiveSum(int[][] values, int num)
public static void testWithFixedValues()
public static void testWithRandomValues()

• generate2DArray() generates a two dimensional array (row X col) with array element values ranging between 0 and 9. Use the random number generator.
• minimumConsecutiveSum() finds the num consecutive numbers either horizontally, vertically, or diagonally, whose sum is minimum
• testWithFixedValues() tests the program with 6 x 7 array and fixed values of elements. Use the first array shown above. It needs to call minimumConsecutiveSum(4) to find the minimum sum of consecutive 4 numbers.
• testWithRandomValues() tests the program with number of rows and columns entered by the user. It calls generate2DArray() to generate a random 2D array. Make sure that the number of rows and columns entered by the user are greater than 4 and less than 11. It asks the user to enter num which is between 3 and 5 to find the minimum consecutive sum.
• you can add more methods if the length of any method exceeds 60 lines of code.
Ask the user for fixed value testing or random value testing. The following shows a sample output. Note that the bold face is used to indicate user input.
> java Homework1-LastName
Enter a choice: (1 for fixed value, 2 for random values) 1
Consecutive four: found ([5,0] – [5,3]) ([0,6] – [3,6]) ([3,2] – [0,5])
0 1 0 3 1 4 1
0 1 6 8 4 0 1
5 6 2 4 8 2 1
6 5 4 1 1 9 1
1 3 6 1 4 0 7
3 3 3 3 4 0 7

Minimum of consecutive four: 4 ([0,6] – [3,6])

> java Homework1-LastName
Enter a choice: (1 for fixed value, 2 for random values) 2
Enter row and column: 7 7
Consecutive four: not found
0 1 0 3 1 6 1
0 1 6 8 6 0 1
5 6 2 4 8 2 9
6 5 6 1 1 9 1 <== Note: your array element values should look different 1 3 6 1 4 0 7 3 3 3 2 4 0 7 1 1 1 2 1 1 3 Enter consecutive number (3, 4, 5): 6 Enter consecutive number (3, 4, 5): 3 Minimum sum of consecutive three: 3 ([6,0] – [6,2]) > java Homework1-LastName
Enter a choice: (1 for fixed value, 2 for random values) 3
Wrong input. Try again!

Enter a choice: (1 for fixed value, 2 for random values) 2
Enter row and column: 4 5
Consecutive four: found ([0,3] – [3,3])
0 1 0 2 1
0 1 6 2 6
5 6 2 2 8 <== Note: your array element values should look different 6 1 1 2 1 Enter consecutive number: 3 Minimum sum of consecutive three: 18 ([0,3] – [1,2]) • Provide four more outputs for random value test with the size of 7x9, 9x9, 10x10, and 5x10 arrays. Important Notes and Requirements: ? Use the Scanner class for the user input. ? Format your code nicely (indenting, layout, etc.) and be sure to use Javadoc comments to explain your code where appropriate. Minimally you should provide a program description with homework title, your name, course, instructor, date and a brief description at the beginning of your program, and method description as shown: // homework1: ... // Name: // Course, semester: // Instructor: // Date finished: // Program description: public class Homework1LastName { ... /** * method description for main */ public void static main(String[] args) { ... } /** * method description for ... */ ... } ? Your output should also be nicely formatted. ? Follow the Java convention to get a full credit. • Start a class name with a capital letter • Start a variable name with a lower case letter • Use descriptive name for the class, variable, member data, and member function. • Be consistent in formatting and indenting your code. Refer to code layout provided in the textbook. ? Modularize your code. If you have a method that contains more than 60 lines of code, there will be a deduction, up to 5%. You can use multiple classes if you want, but it is not required. You can use static functions. ? Do not use packages. If you do, you will get a 3 point deduction. If your IDE automatically added a package name, remove them before submitting them. ? Program that does not compile will not get more than 40 point. ? Program without proper description/comments will lose up to 10 point ? Codes with poor and inconsistent layout will lose up to 5 point ? You can follow the code layout from the codes in the textbook. You can also use the pretty print feature in Eclipse (CTRL + SHIFT + F) to format your codes. ? Use Courier New font or type face font to print your code ? (bonus 10pt) Support warp around feature. That is, Refer to the following code for random number generation by using the Random class. The seed value used is 1, but you can use different values to generate different sequence of random numbers. However, be sure to use 1 for your submitted code. import java.util.Random; public class RandomDemo { public static void main(String[] args) { Random rand = new Random(1); // seed is 1 for (int i = 0; i < 10; i++) System.out.println(rand.nextInt(10)); } }



Create a program that will store all perfect squares between 1 and 10,000
into an array. Once the array is created, print the perfect squares in the following format from greatest to least:

5 X 5 = 25



Create a Java application that allows the user to repeatedly enter a number to find out if it is a perfect number. A perfect number is one that is equal to the sum of all of its positive divisors, excluding itself.
For example, 6 is a perfect number because 1 + 2 + 3 = 6.
28 is a perfect number because 14 + 7 + 4 + 2 + 1 = 28.
The program should:
• prompt the user for a positive number
• print out if the number is a perfect number or not
• then ask if the user would like to enter another number or quit.
See sample below:

Remember to:
• put your name, COP 2800, Chapter 4 Assignment, and date in a comment block at the top of your file
• comment your code
• format your code so it is readable (proper indentation, white space, blank lines, etc.).
Submit your .java file here when you have completed the assignment. Late assignments will not be accepted without an approved excuse.
*Hint: your program will contain a do-while loop for input while the user says yes, a for loop to loop through the divisors to determine if a number is perfect, and a user validation while loop to make sure input is a positive number.



Write a program that accepts a list of up to 100 integers and displays a bar graph showing the frequencies of the values and the corresponding percentage frequency distributions (printed to 1 significant digit).
Example runs are shown below.
Number of values to graph: 3
Enter the integer values separated by a space: 3 3 3
Bar graph for 3:



This assignment is worth 10 points. Your work is due at the beginning of next class. You will
turn in two class printouts.
1. (6 points) Complete the linear search method from today’s lecture. Create a class
containing this method (as a static member) and a main method that, when run, creates
and initializes an array with 100 random numbers and calls your search method for at
least 5 values, three which are in the array and two which are not.
Use System.out.printf to report the results of each search. Test your program and
print out the class.
Note: the size of the array (100) should be defined using a constant field of the class.
2. (4 points) Modify the program to create an array large enough to hold 10,000 random
numbers. Otherwise it should work as before. If you wrote the first version of the
program well, you shouldn’t have to change much at all. Test as before, and print out your
modified class.
3. There is a better way to specify the size of the array that we want the program to create
and fill with random numbers, so we don’t have to change the code every time we want to
test a different array size.
Do you know what it is?
Prepare to discuss this question in class (nothing to turn in).



## Background Information:
### Project overview:
Create an interactive graphical application using input files and mouse event handling.
Your application shall read the given input file and create a visual application that provides output to a user based on mouse clicks.
See the example GIF below for reference while review the [Project Requirements](#project-requirements) below.

![Sample run of applciation](demo.gif)

### Project Requirements:
Your application must function as described below:
1. Upon starting your application, the user shall be prompted with a file chooser to select the input file.
2. After selecting the file (format given below [Input File Format](#input-file-format)), the user should see a graphical display of the rectangles given in the input file selected.
3. The user shall then be able to click inside any of the colored boxes shown and a message box should show the string given in the file for the box clicked.
1. Clicking within the frame, but outside of any boxes, should display an error message.
4. To end the application, the user will click the close button in the top left (Windows) or top right (Mac) of the frame.

### Input File Format
All fields will be given as integers, with the exception of the STRING_TO_DISPLAY fields.


#### Sample data
720 520
10 10 100 150 192 251 30 ADM Grace Hopper
110 10 300 100 249 61 27 Alan Turing
510 10 100 50 156 109 95 Edsger Dijkstra
210 110 500 50 187 151 59 Floyd Warshall
10 160 200 150 10 84 134 Joseph O’Rourke
210 210 200 100 253 104 4 Jin Akiyama
510 210 100 250 134 231 143 Vašek Chvátal
10 310 100 50 15 183 101 Erik Demaine
310 310 200 150 60 110 90 Bjarne Stroustrup
10 360 300 150 147 200 7 Walter Savich

### Implementation Notes:
1. Create a project that is object oriented, therefore there should be several classes.
2. You can assume that the file will match the exact format given above.
3. All rectangles defined in the input data can be assumed to be non-overlapping, so your app should show one message per click.
4. UML
1. The class diagrams should be created in at multiple iterations.
1. The first iteration should be done before you code and should provide a design that the code follows.
2. The second iteration should be completed after the code is complete and should reflex the *exact* class structure of you final program.
3. The class diagrams should include
1. Access specifier (- or +).
2. All instance fields with types.
3. All methods with return type and parameter types.
4. Associations, generalization (inheritance), aggregation and multiplicity .
5. Stereotyping – interface or abstract classes.
4. Create a word document explaining the differences and the rationale behind the differences between the final result of the two series of iterations.
A difference is expected as it is extremely difficult to anticipate every design characteristic prior to coding.