Why does the new ArrayList() in my code errors. I don't get It. Can someone help me, its really urgent. Thanks
public static ArrayList<String> sub = new ArrayList();
public static ArrayList<String> subCourse = new ArrayList();
Write a program that takes two integers as input from the keyboard, representing the number of hits and the number of at-bats for a batter in baseball. Calculate the batter’s hitting percentage and print it, then check if the hitting percentage is above 0.300. If it is, output that the player is eligible for the All Stars Game, otherwise, output that the player is not eligible.
Sample Input
Enter number of hits > 10
Enter number of at-bats > 40
Sample Output
Batters hitting percentage is : 25%
The player is not eligible for the All Stars Game
Write an application for Furniture Company Sdn Bhd, the program determines the total price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany and prompt the user to enter the number of a table. The output is the name of the wood chosen as well as the price of the table. Pine table cost RM100, oak tables cost RM225, and mahogany tables cost RM310. If the user enters an invalid wood code, set the price to 0.
Furniture Company Sdn Bhd also gives an appreciation for the member card holder with 6% off from the total price. The above price is exclude government tax RM 5.60.
Save the file as Furniture.java.
Write an application that allows the user to select from a menu a checking account (1) and a savings account (2) (The balance of these two account should be generated automatically by the program within this range 1 to 100 rand and stored into an array ). Compare the two balances and Display the message “Checking account balance is low” if the checking account balance is less than R10 do the same for the saving account. Again, display the message “Savings account balance is lower or greater then the checking account and visa versa . Save the file as Balance.java.
1. Use of a random function
2. use of an array to store the generated balance
3. use of an if statement
4 . Display of correct output
Create a java program that will count all words in a sentence. The program should have a minimum of two classes.
a) The first class should be named class1, this class will have the following:
The main method (starting point)
The object of class2
Should also call the get method count_words(String str).
b) The second class should be named class2, this class should have the following:
A constructor
A get method named count_words(String str)
c) Construct a flowchart for class1 and class2 both combined
Write a java program that computes the area & perimeter of either a rectangle, a circle or a right-angled triangle. The program should display a menu that enables the user to select the type of figure whose area & perimeter he/she wants to compute. Depending on the users choice, the program should prompt for the dimensions and perform the computations. The output should be: - The type of figure, the dimensions, the area and the perimeter. (NB:The calculation should be for only one figure at any one time.)
using object oriented
Construct a class called Rectangle. A Rectangle has both a length and a width (both positive integers). Access to them should be only inside the class and within the inheritance hierarchy. Then implement the following:
Write an if-else statement that if userTickets is greater than 5, executes award Points = 15 Else, execute award Points = user Tickets. Ex: If user Tickets is 14, then award Points = 15.
1. Create a java program that will count all words in a sentence. The program should have a
minimum of two classes.
1.1 The first class should be named class1, this class will have the following:
The main method (starting point) (5)
The object of class2 (5)
Should also call the get method count_words(String str) (5)
1.2 The second class should be named class2, this class should have the following:
A constructor (5)
A get method named count_words(String str) (10)
1.3 Construct a flowchart for class1 and class2 both combined.
In this task, you are being asked to write a loop in Java.
Write a program that uses while loops to perform the following steps:
a) Prompt the user to input two integers: startingNum and endingNum (startingNum must be
less than endingNum).
b) Output all even numbers between startingNum and endingNum.
c) Output the sum of all even numbers between startingNum and endingNum.
d) Output the numbers and their squares between startingNum and endingNum.
e) Output the sum of the square of the odd numbers between startingNum and endingNum.
1. Create a program called WhileLoops.java. All loops will be written in this file.
2. Create appropriate variables and assign values using a Scanner object.
3. Correctly display appropriate messages.