Java | JSP | JSF Answers

Questions: 3 611

Answers by our Experts: 3 611

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

1.1 A Retail has name, a List containing Items available in the stock and another List containing sold items. [2] 1.2 A Retail have functionality to view available stock, that prints Class name of item, name of Item, size of item and total number of items that have same name, and size. [5] EXAMPLE

ClassName Item name Size Drink coke 1 Drink coke 2

Total

10; // this show that in the list there are 10 coke that are size of 1

5; // this show that in the list there are 5 coke that are size 2 Sizes in drinks means litres.

Hint: Items are the same if their class name, item name and size are the same.

1.3. A retail Shop has a functionality to add item into the stock list. The add item takes a parameter the Item to be added on stock. [2] 1.4 A retail shop also has a functionality to calculate total sales that returns double sum of money made from all sold items. [2]


Create a project to model students with firstname, lastname, age, gender and student number. Create two constructors, one to be used as default and another to include all attributes. Add a class attribute to keep count of all registered students. Use the class attribute to generate student numbers with the following format 22201XYZ, where XYZ is the current count provided by the class attribute. Implement the respective getters and setters for each attribute. Now given a list of student information create the respective objects and print out their details see samples below, make sure the student class has a toString method.


Write an application for a furniture company; the program determines the price of a table. Ask




the user to choose one for pine, 2 for oak, or three for mahogany. The output is the name of the




wood chosen as well as the price of the table. Pine tables cost $100, oak tables cost $225, and




mahogany tables cost $310. If the user enters an invalid wood code, set the price to zero




Write an application for a lawn-mowing service. The lawn-mowing season lasts 20 weeks. The weekly fee for mowing a lot under 4,000 square feet is R25. The fee for a lot that is 4,000 square feet or more, but under 6,000 square feet, is R35 per week. The fee for a lot that is 6,000 square feet or over is R50 per week. Prompt the user for the length and width of a lawn USING JOPTIONPANE, and then display the weekly mowing fee USING JOPTIONPANE , as well as the 20-week seasonal fee. Save the file as Lawn.java.



Marks allocation



1. The use of class and object - 10



2. The use of JOption for input -10



3. The use of JOption for output-10



4. correct out -10

Write an application that prompts the user for a checking account balance and a savings account balance (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 ). Display the message “Checking account balance is low” if the checking account balance is less than R10. Display the message “Savings account balance is low” if the savings account balance is less than R100. Save the file as Balance.java.

Marks allocation 

1. Use of a random function- 5

2. use of an array to store the generated balance -5

3. use of an if statement -5

4 . Display of correct output -10

Using the provided recording and your knowledge from programming 1. Create a program in java that takes in an input from the user and checks whether it’s a number or a word. In case a number is entered the program should print the number to the power 3 and if a word is entered your program should split that word into 2.



Sample Run 1



Enter a number or word: 7



Output 1:



7 to the power 3= 343



Sample Run 2



Enter a number or word: NAMIBIA



Output 2:



The word split in half is : NAMI and BIA

Control Structures: As a build-up from the previous question, consider 3 possible scenarios of input: A character, number, or word. Your program should then do the following:

  • In case the input is a character it should indicate if it’s a vowel or not
  • when a number is entered then it’s should check if it’s a prime
  • Finally, if a word is entered the system should check if it’s a palindrome or not.

     Sample Run 1                               Sample Run 3

             Enter a character, number or word : c                  Enter a character, number or word : 

             Output 1 : C is not a vowel                                     Output 3 : 7 is a prime number  

Sample Run 2

              Enter a character, number or word: programming

Output 2: Programming is not a palindrome

 


Using the provided recording and your knowledge from programming 1. Create a program in java that takes in an input from the user and checks whether it’s a number or a word. In case a number is entered the program should print the number to the power 3 and if a word is entered your program should split that word into 2.

Write a program in Java that ask the user to enter their name, year of birth, and salary. The program must display thier name, age, and salary.

In the file RandomNumbers.java, write a class called RandomNumbers that has three integer instance variables: var1, var2, and var3. Write getter method for each variable: getVar1(), getVar2() and getVar3() and a RandomNumbers constructor that set the initial values of all the instance variables to 0. Then write the following 2 instance methods:


• setRandomValues( ) - accepts a low and high integer values as parameters, and sets var1, var2, and var3 to random numbers (generated using the Random class) within the range of the low and high input values (inclusive).


• getRandomValues( ) - prints out the 3 random numbers in the format: "Random values: var1 var2 var3"


Ex: If the input is:


15 20


the output may be:


Random values: 17 15 19


where 17, 15, 19 can be any random numbers within 15 and 20 (inclusive).



LATEST TUTORIALS
APPROVED BY CLIENTS