What's new

Need help pano to i code?

chiper

Established
Create a java program that uses classes (instance variables, methods, and constructors) and objects to do the following:

accepts three numbers
computes the SUM of all three numbers and determines whether the SUM is odd or even
determine which is the highest and lowest number
Sort the three numbers in ascending order.
Sort the three numbers in descending order.

• Yuuji-kun

zhero25

Grasshopper
i'll just give you an idea about the program... pero ikaw na bahala sa iba

import java.util.Scanner;

public class ArithmeticSmallestAndLargest {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.print("Enter first integer: ");
int number1 = input.nextInt();

System.out.print("Enter second integer: ");
int number2 = input.nextInt();

System.out.print("Enter third integer: ");
int number3 = input.nextInt();
input.close();

int sum = number1 + number2 + number3;
int average = sum / 3;
int product = number1 * number2 * number3;

int largest = number1;
if (number2 > largest)
largest = number2;
if (number3 > largest)
largest = number3;

int smallest = number1;
if (number2 < smallest)
smallest = number2;
if (number3 < smallest)
smallest = number3;

System.out.printf("Sum is %d%n", sum);
System.out.printf("Average is %d%n", average);
System.out.printf("Product is %d%n", product);
System.out.printf("Largest is %d%n", largest);
System.out.printf("Smallest is %d%n", smallest);
}
}

Replies
0
Views
236
Replies
2
Views
184
Replies
1
Views
167
Replies
3
Views
339
Replies
1
Views
341

Members online
1,645
Guests online
935
Total visitors
2,580