Q1 ;
Write a complete Java program that do the following:
Get student information (first name and last name) from the user and store it in the array named studentName (first name and last name are stored in the first and last index of the studentName array).
Print elements of the array studentName using enhanced for statement.
Get student’s ID from the user, store it in the array named studentID and print it
Find and print the sum and average of the array- studentID
Note: Your answer should have the code as text as well as the screenshot of the program output (using your own student’s name and ID as part of your answer). Otherwise, zero marks will be awarded.
Q2 :
Create a class Person to represent a person according to the following requirements: A person has two attributes:
Create a class Product to represent a product according to the following requirements:
Create the class ProductTester with the main method. In this class do the following:
id
name.
a reference number (can’t be changed)
a price
an owner (is a person)
a shopName (is the same for all the products).
Add a constructer to initialize all the attributes to specific values.
Add all setter and getter methods.
A product has four attributes:
Add a constructer without parameters to initialize all the attributes to default values (0 for numbers, “” for a string and null for object).
Add a second constructer to initialize all the attributes to specific values. Use the keyword “this”.
Add the method changePrice that change the price of a product. The method must display an error message if the given price is negative.
Add a static method changeShopName to change the shop name.
Add all the getter methods. The method getOwner must return an owner.
Create a person p1. The person’s name and id must be your name and your student Id.
Create a product with the following information:
Change the price of the product to your age.
Change the shop name to your full name.
Print all the information of the product.
reference = 1.
price = a value from your choice.
owner = p1.
shopName = “SEU”.
Note: Your answer should have the code as text as well as the screenshot of the program output. Otherwise, zero marks will be awarded.
Q3:
Write a java program that do the following:
Create a super class named employee which has three attributes name, age and salary and a method named printData that prints name, age and salary of an employee.
Provide two classes named programmer and database specialist (DatabasePro).
Provide a class Main that creates programmer and database specialist then initialize and print their respective information.
Each one of these classes extends the class employee. Both classes; programmer and the DatabasePro inherit the fields name, age and salary from employee. For the programmer, we add a language attribute and for the specialist (DatabasePro), we add a database tool attribute.
Each one of these classes has only the method printData(). This method prints the data of the employee (i.e., name, age and salary by invoking printData() in super class)as well as printing the special data for programmer( i.e., language) and for DatabasePro( i.e.,databaseTool).
Note: Your answer should have the code as text as well as the screenshot of the program output. Otherwise, zero marks will be awarded.
Consider the following information, and answer the question below. China and England are international trade…
The CPA is involved in many aspects of accounting and business. Let's discuss some other…
For your initial post, share your earliest memory of a laser. Compare and contrast your…
2. The Ajax Co. just decided to save $1,500 a month for the next five…
How to make an insertion sort to sort an array of c strings using the…
Assume the following Keynesian income-expenditure two-sector model: AD = Cp + Ip Cp = Co…