Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

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

Survival of the Biggest (JAVA)

by CodeChum Admin

Looping a number and taking away each digit of it is so much fun, but I wanted to try out a much more complex task: getting the largest digit among them all.

Think you can handle the job?


Instructions:

  1. Input a non-zero positive integer.
  2. Using the same concept as the previous problem, figure out how to separate the digits of a number and determine which of the digits is the largest one, using a while. Afterwards, print the largest digit.
  3. Tip #1: Create another variable that will hold the largest digit. Initial its value to a negative integer, like -1, outside the loop.
  4. Tip #2: Everytime you get the rightmost digit, check if it is greater than the current largest digit. If it is, set it as the new largest digit.

Input

A line containing an integer.

214

Output

A line containing an integer.

4

binary to decimal with checking


  1. Decimal to Binary 365₁₀
  2. Decimal to Binary 1022₁₀
  3. Decimal to Binary 73₁₀
  4. Decimal to Binary 1577₁₀
  5. Decimal to Binary 64₁₀
  6. Decimal to Binary 2661₁₀

7. Decimal to Binary 3110₁₀

8 Decimal to Binary 51₁₀

9 Decimal to Binary 507₁₀

10 Decimal to Binary 4001₁₀


Create a short program that will print 123467.89 as currency using NumberFormat.



Sample Output:


------------------------------------------------------------------


I have ₱1,234,567.89 in my bank account.

Create a short program that will generate a random number from 0 to 100 while using Math.random and Math.round command.


Submit your answers by attaching a screenshot of your program's source code and 3 screenshot of it's output.



Write a program that declares and initializes an array of 7 integers. The program uses these static methods to perform different operations on the array:

void printArray(int[] arr) – takes the array as parameter and prints the array in horizontal order

int sumOfArray(int[] arr) – takes the array as parameter and returns the sum of the array

int getHighest(int[] arr) – takes the array as parameter and returns the highest value in the array

int resetArray(int[] arr) – takes the array as parameter and resets the value of each element to 0


Sample output:

Here’s the array: 

3 1 3 2 1 9 1

Sum: 20

Highest: 9

Here’s the array: 

0 0 0 0 0 0 0




Create a program that will allow the user to input ten numbers into an array, using values of 0 to 99, and print out all numbers except for the largest number and the smallest number.

Sample Output:

Enter the Numbers >> 10 20 10 40 50 60 70 80 90 99

Output >> 20 40 50 60 70 80 90

Try Again Y/N?


Write a program to input 10 numbers and output the sum of the two largest values in the sequence.


Sample Output:


Enter the Numbers >> 10 2 3 4 5 6 7 9 9 10


Sum >> 20




Try Again Y/N?

Jaya Jusco (JJ) Sdn Bhd needs you to develop an application to calculate their customer JJ point’s reward. Define a class named Customer with the following variables declarations:


String CustName;

String CustAddress;

int pointRewards;

 

  1.  Provide a default constructor and another constructor with three parameters. The constructor with parameters will assign the three values (String CustomerName, String CustomerAddress, int point). Define a public instance method named calculatePoint()to calculate the customer rewards if the point is greater than 300 points. The formula indicates that if the point is greater than 300 points, the system will add up extra 50 points.
  2. Define another class named Testing to test the Customer class. Use the Scanner method to get the CustomerName, CustomerAddress and point values from the user. Declare class and create object Customer. Call the calculatePoint( ) method to display the current customer points reward.  

Create a java program which allows the user to enter two values (Using JOptionPane) to be divided. The program catches an exception if either of the entered values is not an integer.

Declare three integers—two to be input by the user and a third to hold the result after dividing the first two. The numerator and denominator variables must be assigned starting values because their values will be entered within a try block. Also declare an input String to hold the return value of the JOptionPane showInputDialog() method.int numerator = 0, denominator = 0, result; String display;

Add a try block that prompts the user for two values, converts each entered String to an integer, and divides the values, producing result(Cast the result to a double).

Add a catch block that catches an Arithmetic Exception object if division by 0 is attempted. If this block executes, display an error message, and force result to 0.


Create a class named Invoice containing fields for an item number, name, quantity, price, and total cost. Create a constructor to pass the value of the item name, quantity, and price. Also include displayLine() method that calculates the total cost for the item (As price times quantity) then displays the item number, name, quantity price, and total cost. Save the class as Invoice.java.


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS