Machine Problem 5.4.
Write a program using two-‐dimensional arrays that determines the ODD numbers among the12 input values typed fromthe keyboard and prints the list of these ODD numbers.
Sample input/output dialogue:
Enter twelve numbers: 8 9 10 7 25 30 69 101 798 10111 10023
Odd numbers are: 9 7 25 69 101 10111 10023
Machine Problem 5.3.
Write a program using one-‐dimensional array that accept five input values from the keyboard. Then it should also accept a number to search. This number is to be searched if it is among the five input values. If it is found, display the message “Searched number is found!”, otherwise display “Search number is lost!”.
Friend and Enemy
A group of F friends went to a haunted house.Each member was given a shirt with a number on it ranging from 1 to F. As they entered the haunted house, one of them was kidnapped and an enemy joined them.But unfortunately, the enemy didn't wear the shirt with the same number as the kidnapped one, instead wore the same as some other person.Find the numbers on the shirts of the enemy and the kidnapped person.
Input
The input is a single line containing space-separated positive integers from 1 to F.
Output
The output should be a single line containing the shirt numbers of the enemy and kidnapped person separated by a space.
Explanation
The given array is 3 1 5 2 1.
In the range from 1 to 5, the number 1 has occured twice and 4 is the missing number. So, 1 belongs to the enemy's shirt, and 4 belongs to kidnapped.Hence, the output should be 1 4.
Sample Input1
3 1 5 2 1
Sample Output1
1 4
Sample Input2
1 2 2 4
Sample Output2
2 3
Create a program that will compute the simple interest loans in the bank. The program will ask the user to input the principal amount , the rate per annum and the time (in years).
Given the formula:
Interest = Principal Amount * RateperAnnum * Time / 100
Design a Car model class under package :package6 with the following attributes:
Member Field Name
Type
licenceNumber
String
Model
String
currentMileage
Double
engineSize
Integer
Mark at 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 Current Mileage engine Size values should to findCarList method as argument well as Car array (with size 10).
findCarList method Car class follows:
will take current Mileage engine Size as (with size 10)
displays List of than current Mileage and engine Size (both) for the given current Mileage engine values.
there are cars, then shows cars found".
Design a Car model class under package :package5 with attributes:
Member Field Name
Type
licenceNumber
String
Model
String
currentMileage
Double
engineSize
Integer
Mark all the attributes as private & Create default & parameterized constructors.
Design another class as Main under package :package5, 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 sortCarList method which return sorted car array and then display all car information on console.
Design sortCarList method in Car class as follows:
• it will take a car array ,return car array
it will sort array based on model value given in each car as its information.
Design aCar model classunder package :package4 with the following attributes:
Member Field Name
Type
licenceNumber
String
Model
String
currentMileage
Double
engineSize
Integer
Mark all the attributes as private & create appropriate Getters & Setters
Design another class as Mainunder package :package4, 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 model name and display then within this method.
Model name should be taken from Main class and pass to find CarList method as argument as well as Car array (with size 10).
Design findCarList method in Car classas follows:
• it will take a model(car model) as parameter and array of cars (with size 10)
• displays List of cars for the given model from the list.
• If there are no cars, then shows "No cars found".
Design a Car model class under package :package3with the following attributes:
Member Field Name
Type
licenceNumber
String
model
String
currentMileage
Double
engineSize
Integer
Mark all the attributes as private & create appropriate Getters & Setters
Design another class as Mainunder package :package3, where you need to implement logic as follows:
You need to take the number of cars as input and then take each car's necessary information and put them in array.
Then at end show them in well-designed format.
Create a class named as Customerunder package :package2, which contains following private variables/ attributes,
Member Field name
Type
id
Long
name
String
gender
Character (M/F)
String
contact Number
String
Mark all the attributes as private
Add a default constructor and a parameterized constructor to take in all attributes.
Create a separate class Main under package :package2, within it's main() method, make 2 Customer objects and then compare between these Customers.
Two members are considered same if they have same email and contactNumber. Implement the logic in the appropriate function. (override equals method in class Customer)
Sample Input:
Customer1:
ld: 45
Name: John
Gender: M
Email: john@a.com contact number: +997-4854-7485965123
Customer2:
ld: 12
Name: Marc
Gender: M
Email: marc@a.com
Contact number: +997-4854-7485965123
Sample Output:
Customer 1 and Customer 2 are different