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:
Input
A line containing an integer.
214
Output
A line containing an integer.
4
binary to decimal with checking
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;
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.