Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int base = 0, height = 0; double width; char answer = 0; int count = 0; while (true){ System.out.print("Base = "); base = sc.nextInt(); System.out.print("Height = "); height = sc.nextInt(); width = (double)(base * height) / 2; System.out.printf("Triangle width = %.1f\n", width); System.out.print("Continue? "); answer = sc.next().charAt(0); if ((answer == 'Y') || (answer == 'y')) continue; else break; } } } | cs |