Java | JSP | JSF Answers

Questions answered by 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

Correct the error in the following code : there is more than 1 error :


1-

importjava.util.Scanner; // import Scanner class publicclass We {

publicstaticvoid main(String[] args) {

Scanner input = newScanner(System.in);// create Scanner object System.out.println("number:");

intg= input.nextInt(); // Declare and read

switch(g==);

case1 :System.out.println("case1"); break;

case2 :System.out.println("case2"); break;

    


default :System.out.println("default"); }

}


2-

charg= 'a'; switch(g)

{

Case r :System.out.println("case1");

break;

case u: System.out.println("case2"); break;

default :System.out.println("default"); }


6-Write a program to calculate the area of a circle. Use the formula Pi * r * r to work the program. Remember Pi is a constant and r is a variable entered by the user at runtime (once the program is running). Format the answer to 2 decimal places.


Rewrite the following program using Switch:

if (x == 1) {

system.out.println("x is 1");

}

else if (x == 2) {

system.out.println("x is 2");

}

else {

system.out.println( "value of x unknown"); }



Using a switch statement, write a program that prompts the user for a numeric code and two operands. The numeric codes of 1, 2, 3, and 4 represents addition, subtraction, multiplication, and division respectively. Before division, your program should check whether the second operand is not zero. If it is, it should display “Division by zero not allowed” to the screen.

                     


Write a java program for the following-

Class person

Derive two classes-student and employee [identify inheritance]

For student

Input: Name, roll no, marks in 4 subjects (use arrays of object]

Output: student information, total marks [create necessary function, Use of constructor

For Employee

Input: empno, empname, basic

Process:

a. DA=50%of basic

N

b. HRA=25%of basic

c. CCA=Rs240/-

d. PF=10%of basic


You have been requested to create a program that that helps the Namibian Defence Forces’ (NDF) Captain to calculates the BMI of a person (BMI = weight/height2) and also determine whether the person has also completed running 10 km in the required time. Men should complete 10km in less than 60 minutes for them to be accepted. Women should do that under 80 minutes. Both males and females are accepted if their BMI is less than 25 and greater than 18.5. For 2018 intake, there are already 6 males selected and 1 female.

Sample Run 1

Welcome to NDF Captain's Selection Aid.

***************************************

Gender: male

Mass in kilograms: 82

Height in metres: 1.82

Time for completing 10 km in minutes: 45

Output1: Candidate Selected! The number of males is now 7.





Consider an array MARKS[20][5] which stores the marks obtained by 20 students in 5 subjects. Now write a program to

(a) find the average marks obtained in each subject.

(b) find the average marks obtained by every student.

(c) display the scores obtained by every student and grades according to the average marks obtained by every student


Write java program to read and write string using file.


Explain the concept of De-serialization.


Briefly explain the Thread Life cycle.


LATEST TUTORIALS
APPROVED BY CLIENTS