You are on page 1of 2

Ian Murimi.

Tracy Muthoni.
Jackton Otieno.
Florence Muchomba

1. We created a program that asks for input of a pool (length, width and height). It then calculates
the volume of the pool using the later data. The result is then converted and displayed in liters.
With an input of know rate the program manipulates the value of volume and gives the time it
would take to fill the pool in hours.
2. The second program applies the loop technique given an output and only stops when the user
gives a command. The program takes input of sides of a triangle and determines whether it’s an
equilateral, scalene or isosceles triangle.

import javax.swing.JOptionPane;

public class Rectangle {

public static void main(String[] args) {

String input;

double side1, side2, side3;

int choice = JOptionPane.YES_OPTION;

while (choice == JOptionPane.YES_OPTION) {

input = JOptionPane.showInputDialog("Enter side 1");

side1 = Double.parseDouble(input);

input = JOptionPane.showInputDialog("Enter side 2");

side2 = Double.parseDouble(input);

input = JOptionPane.showInputDialog("Enter side 3");

side3 = Double.parseDouble(input);

if (side1 <= 0 || side1 > 100 || side2 <= 0 || side2 > 100 || side3 <= 0 || side3 >
100) {

JOptionPane.showMessageDialog(null, "Invalid input");

} else if (side1 == side2 && side2 == side3) {


JOptionPane.showMessageDialog(null, "Equilateral");

} else if (side1 == side2 || side2 == side3 || side1 == side3) {

JOptionPane.showMessageDialog(null, "Isosceles");

} else {

JOptionPane.showMessageDialog(null, "Scalene");

choice = JOptionPane.showConfirmDialog(null, "Do another?");

You might also like