PROGRAM 3 – Times tables
You must write a small application in JAVA that will read in a positive integer and then display the times tables for that number, from 1 to 12.
Your program must
1. Read in the integer as input.
2. Calculate and display the complete times tables up to 12 for that integer.
3. If a zero or any number less is entered, an error message must be displayed and the user must be allowed to input another value.
PROGRAM 2 – Maths Calculator
Write a small application in JAVA that reads in two integers, and then asks the user to type in a character to indicate what calculation must be done with the two numbers, viz:
A to add
S to subtract
M to multiply
D to divide
Display the result of the calculation.
The output of sample runs of the program is given below (the text in bold was typed by the user).
Please use the SAME wording/messages/labels as shown.
Sample execution run 1 Sample execution run 2
Enter the first number: 27
Enter the second number: 9
What would you like to do?
A to add
S to subtract
M to multiply
D to divide
Enter choice: s
27 minus 9 is 18.
Enter the first number: 15
Enter the second number: 0
What would you like to do?
A to add
S to subtract
M to multiply
D to divide
Enter choice: D
**Error** Cannot divide by zero.
PROGRAM 1 – Shopper Calculator
You must write a small application in JAVA that can assist a shopper by calculating the total price of the items that he or she wants to buy and displaying a tillslip-like list of the products, their prices and the total due.
Your program must
1. Read the name and price of five items as input.
2. Calculate the total price for the items.
3. Display all the item names and prices.
4. Display the total due for all items.
Design a Car model class under package packages with the following attributes:
Member Field Name
licenceNumber
Type
String
String
Double
Model
currentMileage engine Size
Integer
Mark all the attributes as private & Create default & parameterized constructors
Design another class as Main under package packages, where you need to implement logic as follows
Declare an array as Car with size N where N is to be accepted from user Take N Car's information from user and store them in specified array Call sortCarlist method from Main class to get all cars information sorted based on Model name and display then within Main class after returning back
from the specified method From Main class car array need to pass within sortCarLast method which return sorted car array and then display all car information on console.
Design sortCarlist method in Car clast, as follows: will take a car array and retam car array
it will sort array based on model value given in each car as its information
Create a class called Match that will have team the class must have the following data members and methods:
Data Members:
• This class has two data members named HomeTeam and VisitorTeam which are of type Team, they will store that two teams that will play the Match.
Methods:
• This class doesn’t have a default constructor, it only has one constructor which receives two Team object that will be assigned to HomeTeam and VisitorTeam.
• setTeams(),which receives two Team object that will be assigned to HomeTeam and VisitorTeam.
• playMatch(), simulates match play by calling the scoreGoals methods of each team.
• getPlayGound(), returns the ground of play which is the HomeGound of the HomeTeam.
• isDrawMatch(), will return true if the Match is a draw and false if there is a winner. The match is a draw if the goals of the teams are equal.
• getWinner(), returns the team which won the match, a team wins if its goals is higher than the goals of the other team.
Create a java program of following output.
Output:
My name is Nico Sumpang
The sum is: 10
The difference is: 5
The product is: 20
The quotient is: 2.5
St. Augustine SY 2020-2021
Design a Car model class under package :package6 with the following attributes:
Member Field Name
Type
licenceNumber
String
Model
String
currentMileage
Double
engineSize
Intege
Mark all the attributes as private & create appropriate Getters & Setters
Design another class as Main under package :package6, where you need to implement logic as follows:
Declare an array as Car with size 10.
Take 10 Carà ƒ ¢ € ™s information from user and store them in specified array.
Call findCarList method from Main class to get all cars information related to a given current Mileage & engine Size
Current Mileage & engine Size values should be taken from Main class and pass to findCarList method as argument as well as Car array (with size 10).
Design findCarList method in Car class as follows
Create a class called OneDimArray then create a private generic array of type Object inside class, initialize array using constructor then implement the following methods inside class, then create a driver class called OneDimArrayTest for testing your program. Test your program with integers.
· + Boolean addItem(item)
· + Boolean addItemAt(index, item)
· + Object removeItemAt(index)
· + Object removeItem(index, item)
· + Object deleteItemIfOdd(item)
· + Boolean isEmpty()
· + Boolean isFull()
· + Object getItemAt(index)
· + Boolean setItem(index, item)
· + void swapItems(index1, index2)
2. Write a program in Java to take the postfix form of a mathematical expression. Evaluate the postfix expression and print the result. The postfix expression will contain single-digit operands and ‘+’, ‘-‘, ‘*’, and ‘/’ operators. You can use relevant Java built-in classes in your code. The sample inputs/ outputs are given below: Sample inputs and outputs: (User’s inputs are shown in bold) The postfix expression: 543*+82/- The final result: 13