Top Movies JAVA

Top Movies JAVA 1

Write a Java program to do the following :• Use this file for input movies.txt (see attached file)• Load the records to an array• Sort the movies by Year• Report1 – Output Report1 to console (see sample report)Current Date and Time
“Top Movies of All Time – Sorted by Year”
List all movies in order by year
• Sort the Array by Title (you will need to figure out a way to do this)• HINT: There are several ways that you can manipulate this data to get it sorted by title. One way is to use the .replace() string method or .replace() Arrays method.• Report2 – Output Report2 to ConsoleCurrent Date and Time
“Top Movies of All Time – Sorted by Title”
List all movies in order by Title
• Output to a txt file named moviesYYYY-MM-DD_hh-mm.txt, all movies released from 2000 to present. See the “Research Challenge” below for specifics on formatting the file name.•METHODSsFileToArray() – setup this method to be able to open ANY file of String data and input that data into an array. You determine the appropriate arguments and return value.
Ask the user to enter the name of the file and the number of records in the file.
Use this method in your program, when you load your array of movies.
sFileOutput – setup this method to be able to output ANY String data to a file. You determine the appropriate arguments and return value.
Use this method in your program, when you write your 2000 – Present movies to a file.
report1() – setup this method to create and output report 1. You determine the appropriate arguments and return value.
report2() – setup this method to create and output report 2. You determine the appropriate arguments and return value.
Write all the methods in the SAME class file as your main(). (This will make it easier for me to grade).Challenge (REQUIRED) :• Format the file name of your .txt output file with the current date and time as follows.moviesyyyy-mm-dd-hh_mm.txt. This is called a dateTime stamp and is a useful way to create an archive of files. Each time your program creates a new file it will automatically have a unique file name identified by the current date and time it was created.
For example: Your file would be movies2021-11-24-14_54.txt if it was created on November 24th, 2021 at 2:54pm.

Savings Account

Savings Account 2

Design a Savings Account class that stores a savings account’s annual interest rate and balance. The class constructor should accept the amount of the savings account’s starting bal ance. The class should also have methods for subtracting the amount of a withdrawal, adding the amount of a deposit, and adding the amount of monthly interest to the balance. The monthly interest rate is the annual interest rate divided by twelve. To add the monthly inter est to the balance, multiply the monthly interest rate by the balance, and add the result to the balance.Test the class in a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, andthe number of months that have passed since the account was established. A loop should then iterate once for every month, performing the following:a. Ask the user for the amount deposited into the account during the month. Use the class method to add this amount to the account balance.b. Ask the user for the amount withdrawn from the account during the month. Use the class method to subtract this amount from the account balance.c. Use the class method to calculate the monthly interest.After the last iteration, the program should display the ending balance, the total amount of deposits, the total amount of withdrawals, and the total interest earned.

Payroll JAVA

Payroll JAVA 3

Design a Payroll class that has fields for an employee’s name, ID number, hourly pay rate, and number of hours worked. Write the appropriate accessor methods and a constructor that accepts the employee’s name, ID number, hourly pay rate, and number of hours worked as arguments.
The class should also have 2 methods:
1. getGrossPay() that returns the employee’s gross pay, which is calculated as the number of hours worked multiplied by the hourly pay rate.
2. getEstimatedTax() that returns the employee’s estimated tax, which is 30% of the gross pay.
Write a program that demonstrates the class by creating two Payroll objects, then asking the user to enter the data for two employees. The program should display employee’s name, ID number, the amount of gross pay earned and the amount of estimated tax. Here is an example of the program’s output:Enter the first employee’s name: Name One
Enter the first employee’s ID number: 1000
Enter the first employee’s hourly pay rate: 100
Enter the number of hours worked by the first employee: 160
Enter the second employee’s name: Name Two
Enter the second employee’s ID number: 2000
Enter the second employee’s hourly pay rate: 50
Enter the number of hours worked by the second employee: 160
Employee Payroll Data
Name: Name One
ID Number: 1000
Hourly pay rate: 100.0
Hours worked: 160.0
Gross pay: $16000.0
Est. Tax: $4800.0
Name: Name Two
ID Number: 2000
Hourly pay rate: 50.0
Hours worked: 160.0
Gross pay: $8000.0
Est. Tax: $2400.0

ArrayAdd JAVA

ArrayAdd JAVA 4

To complete this program you will need to be able to use arrays in Java and loop over them to perform some calculations.Arrays in Java cannot be changed. So when you want to add elements to an existing array but you have reached the bounds of the array, you must make a new array that is larger and move all the items into it. This can be done using loops. Here is an example…String[] originalArray = {“A”, “B”, “C”};// Make a new array that is one element bigger than the original array.
String[] updatedArray = new String[originalArray.length + 1];// Loop over the original array. Place each element into the same position in the updated array.
for (int i = 0; i < originalArray.length; i++) { updatedArray[i] = originalArray[i]; }updatedArray[updatedArray.length - 1] = "D"; You can view and experiment with the code in this live environment (Links to an external site.). Spend time with this. Make sure you understand how it works and everything that is happening.Now you are going to write a program to collect scores (they range from 0 to 100) and then provide some statistics about the set of data. Write a program in Java that asks the user to enter a score. You will store this score into an array. This will happen over and over again until the user enters enter -1 to stop (provide instructions in the program to this effect). Since you don't know how long this will go on, you must continue to resize the array to meet the amount of data entered in the program. When user has finished entering all the scores, the program should iterate over the array and find the number of scores entered, the sum of the scores, the mean, the lowest and the highest score. It should display this information to the user.You may only use simple arrays. You cannot import any new classes aside from the scanner which will be required to capture the user input. Use of outside classes not earn any points.


TaxCal JAVA 5

Computing TaxProblem Description:The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. Table 3.2 shows the rates for 2009. If you are, say, single with a taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%. So, your tax is $1,082.5.Table 1
2009 U.S. Federal Personal Tax Rates
Marginal Tax Rate Single Married Filing Jointly or Qualified Widow(er) Married Filing Separately Head of Household
10% $0 – $8,350 $0 – $16,700 $0 – $8,350 $0 – $11,950
15% $8,351– $33,950 $16,701 – $67,900 $8,351 – $33,950 $11,951 – $45,500
25% $33,951 – $82,250 $67,901 – $137,050 $33,951 – $68,525 $45,501 – $117,450
28% $82,251 – $171,550 $137,051 – $208,850 $68,525 – $104,425 $117,451 – $190,200
33% $171,551 – $372,950 $208,851 – $372,950 $104,426 – $186,475 $190,201 – $372,950
35% $372,951+ $372,951+ $186,476+ $372,951+You are to write a program to compute personal income tax. Your program should prompt the user to enter the filing status and taxable income and compute the tax. Enter 0 for single filers, 1 for married filing jointly, 2 for married filing separately, and 3 for head of household.Here are sample runs of the program:Sample 1:
Enter the filing status: 0
Enter the taxable income: 100000
Tax is 21720.0Sample 2:
Enter the filing status: 1
Enter the taxable income: 300339
Tax is 76932.87Sample 3:
Enter the filing status: 2
Enter the taxable income: 123500
Tax is 29665.5


UserNamePasswordValidation 6

Create a class the asks the user for their name. Loop and call the validateName method that checks the name against the valid name array. If there is a match move on to the next section. If it does not match loop and ask again for the name until there is a match. The validateName method has one String as an argument and returns a Boolean value of true or false. It checks the incoming argument against the array of valid usernames that you create. It should have at least three names. If a valid name is found then return true, else return false.
Once the validate name is passed then the main method will loop again and ask the user for their password. It will then pass the password to the validatcPassWord method that will check the password against the password array. If they match, continue. If they don’t match loop and ask the user to try again. The validate password array should have three valid passwords at least. The same number as valid login names. The validatePassWord method takes one String as an argument and returns a Boolean value. If the incoming String matches one of the passwords in the password array, then return true, otherwise return false. Once the password is validated, display “Login successful” from the main method.

Copenhagen Transit

Copenhagen Transit 7

Write a program that computes the fare on the Copenhagen Transit system given two inputs from the user:The zone number: 1 or more
The passenger type: adult or childYour prompts to the user must be :Enter zone number :
Enter adult or child :
The fare on Copenhagen Transit is specified as follows:If the zone is 2 or smaller and the ticket type is “adult,” the fare is 23.0.
If the zone is 2 or smaller and the ticket type is “child,” the fare is 11.5.
If the zone is 3 and the ticket type is “adult,” the fare is 34.5.
If the zone is 3 or 4 and the ticket type is “child,” the fare is 23.0.
If the zone is 4 and the ticket type is “adult,” the fare is 46.0.
If the zone is greater than 4, the fare is -1.00 (since your calculator does not handle inputs that high).Your output must be in the format:The fare for adultOrChild to zone number zoneNumber is *****A sample run of the program with inputs 3 and adult must look like:Enter zone number : 3
Enter adult or child : adult
The fare for adult to zone number 3 is $34.50Please note that your class should be named CopenhagenTransit.

Sieve of Eratosthenes

Sieve of Eratosthenes 8

Sieve of Eratosthenes
A prime number is any integer greater than 1 that’s evenly divisible only by itself and 1. The Sieve of Eratosthenes is a method of finding prime numbers. It operates as follows:
a) Create a primitive-type boolean array with all elements initialized to true. Array elements with prime indices will remain true. All other array elements will eventually be set to false.b) Starting with array index 2, determine whether a given element is true. If so, loop through the remainder of the array and set to false every element whose index is a multiple of the index for the element with value true. Then continue the process with the next element with value true. For array index 2, all elements beyond element 2 in the array that have indices which are multiples of 2 (indices 4, 6, 8, 10, etc.) will be set to false; for array index 3, all elements beyond element 3 in the array that have indices which are multiples of 3 (indices 6, 9, 12, 15, etc.) will be set to false; and so on.When this process completes, the array elements that are still true indicate that the index is a prime number. These indices can be displayed. Write an application that uses an array of 1,000 elements to determine and display the prime numbers between 2 and 999. Ignore array elements 0 and 1.

Saving Account Class

Saving Account Class 9

Saving Account Class
Create class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit. Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12—this interest should be added to savingsBalance. Provide a static method modifyInterestRate that sets the annualInterestRate to a new value. Write a program to test class SavingsAccount. Instantiate two savingsAccount objects, saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to 4%, then calculate the monthly interest for each of 12 months and print the new balances for both savers. Next, set the annualInterestRate to 5%, calculate the next month’s interest and print the new balances for both savers.

Game of Craps

Game of Craps 10

Game of Craps
Write an application that runs 1,000,000 games of craps code in discussed in chapter 6 (also given in appendix 1 of this assignment file) and answers the following questions:
a) How many games are won on the first roll, second roll, …, twentieth roll and after the twentieth roll?
b) How many games are lost on the first roll, second roll, …, twentieth roll and after the twentieth roll?
c) What are the chances of winning at craps? [Note: You should discover that craps is one of the fairest casino games. What do you suppose this means?]
d) What is the average length of a game of craps?
e) Do the chances of winning improve with the length of the game?

Appendix 1 – Game of Craps Code
// Fig. 6.9:
// Craps class simulates the dice game craps.
import java.util.Random;
public class Craps
// create random number generator for use in method rollDice
private Random randomNumbers = new Random();
// enumeration with constants that represent the game status
private enum Status { CONTINUE, WON, LOST };
// constants that represent common rolls of the dice
private final static int SNAKE_EYES = 2;
private final static int TREY = 3;
private final static int SEVEN = 7;
private final static int YO_LEVEN = 11;
private final static int BOX_CARS = 12;
// plays one game of craps
public void play()
int myPoint = 0; // point if no win or loss on first roll
Status gameStatus; // can contain CONTINUE, WON or LOST
int sumOfDice = rollDice(); // first roll of the dice
// determine game status and point based on first roll
switch ( sumOfDice )
case SEVEN: // win with 7 on first roll
case YO_LEVEN: // win with 11 on first roll
gameStatus = Status.WON;
case SNAKE_EYES: // lose with 2 on first roll
case TREY: // lose with 3 on first roll
case BOX_CARS: // lose with 12 on first roll
gameStatus = Status.LOST;
default: // did not win or lose, so remember point
gameStatus = Status.CONTINUE; // game is not over
myPoint = sumOfDice; // remember the point
System.out.printf( “Point is %d\n”, myPoint );
break; // optional at end of switch
} // end switch
// while game is not complete
while ( gameStatus == Status.CONTINUE ) // not WON or LOST
sumOfDice = rollDice(); // roll dice again
// determine game status
if ( sumOfDice == myPoint ) // win by making point
gameStatus = Status.WON;
if ( sumOfDice == SEVEN ) // lose by rolling 7 before point
gameStatus = Status.LOST;
} // end while
// display won or lost message
if ( gameStatus == Status.WON )
System.out.println( “Player wins” );
System.out.println( “Player loses” );
} // end method play
// roll dice, calculate sum and display results
public int rollDice()
// pick random die values
int die1 = 1 + randomNumbers.nextInt( 6 ); // first die roll
int die2 = 1 + randomNumbers.nextInt( 6 ); // second die roll
int sum = die1 + die2; // sum of die values
// display results of this roll
System.out.printf( “Player rolled %d + %d = %d\n”,
die1, die2, sum );
return sum; // return sum of dice
} // end method rollDice
} // end class Craps

New Download