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


debug the code for displaying numbers 1 to 10 using do￾while loop.

Class doWhile

{

public static void main(String[] args)

{

int num =1;

do

{

System.out.println(num);

}while(num>=10)

}

}


The following code results in compile time error. Identify the error.

public static void display ()

{

int n =123456;

float f =100.12;

System.out.println(“Float value ” +f);

}


Create a program that will String input. Based on the number of inputs,


the USER will decide what shape it is circle,rectangle,square and triangle.


(1 input – circle, 2 inputs – square or rectangle, 3 inputs - triangle).


The program will then display the shape type, details, perimeter and area.


USE TRY AND CATCH



Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar15


Type:Circle


Radius:15


Perimeter:94.2


Area:706.5




Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar15


Type:Rectangle


Length:24


Width:12


Perimeter:72.0


Area:288.0




Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar15


Type:Square


Side:12


Perimeter:48.0


Area:144.0




Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar 9 15 12


Type:Triangle


Sides:9, 15, 12


Perimeter:36.0


Area:54.0




Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar 9 15 12 8


Invalid input




class:


-TestShape


-Shape


-Circle


-Rectangle


-Square


T-riangle


Using nested loops, write code to produce the following output. (8 marks)


NB: Use only two loops.


1 2 3 4 5 6 7 8


1 2 3 4 5 6 7


1 2 3 4 5 6


1 2 3 4 5


1 2 3 4


1 2 3


1 2


1

Write a program that accepts a list of integers and computes their sum. The program should allow the user to enter any number of integers but an input of zero should terminate the list. For example if the user enters 2 5 6 12 8 2 0 the sum should be 35. If he/she enters 2 4 5 0 the sum should be 11 and if he enters 5 4 6 0 12 43 2 the sum should 15 i.e. only numbers before zero are summed. The rest are ignored and the program terminated. (5 marks)



Write the pseudocode for the following statement:


The program is to input an examination mark and test it for the award of a grade. The


mark is a whole number between 1 and 100.The program will receive the grade from the


user until the number of entered students is equal to 10 and this should now generate a


report for all the grade entered with the award description. Grades are awarded


according to the following criteria:


>= 80 Distinction


>= 60 Merit


>= 40 Pass


< 40 fail

Write the pseudocode for the following scenario. The final exam marks for 10 students



are 65, 45, 78, 65, 89, 65, 79, 67, 75, and 63. The marks are stored in an array. Find:



• The student with the highest mark.



• The student with the lowest mark.



• The total marks for all the students.



• The overall average.

I'm really fond of even numbers, you know? That's why I'll be letting you make another even number problem yet again. This time, you need to print from a range of two inputted numbers, n1 and n2 (inclusive), all the even numbers from n2 down to n1, in descending order.





Analyze the following Java Program and complete the missing codes:


public class Tut1_17032021_Qb {

public static void main(String[] args){

String name;

String AssessedValueString;

String outputStr;

name = JOptionPane.showInputDialog("Enter Property Name and press ok!");

AssessedValueString = JOptionPane.showInputDialog("Enter Assessed value and press

ok!");

AssessedValue = Double.parseDouble(AssessedValueString);

TaxableAmount = AssessedValue*TaxablePercentage;

PropertyTax = (TaxableAmount/100)*TaxRate;

outputStr = "Property Name: " + name + "\n" + "Assessed Value: R " + AssessedValue + "\n"

+

"Taxable Amount: R " + TaxableAmount + " \n" + "Tax Rate for each R100.00:

" + TaxRate + "

\n" + "Property Tax : R " + PropertyTax;

JOptionPane.showMessageDialog(null, outputStr, "Mafikeng Local Municipality",

JOptionPane.INFORMATION_MESSAGE);


 


Write a program that accept three numbers, 

multiply the first and the third numbers 

and divide the results by the second number. 

The output for the program should be as follows:

 The first number is 

The second number is 

The third number is 

Result is


LATEST TUTORIALS
APPROVED BY CLIENTS