Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Input dan output dari program.
- * Menginput besar jari-jari dan warna lingkaran.
- * Output berupa kalimat yang berisi luas dan warna lingkaran.
- *
- * Benito Dannes
- */
- import java.util.Scanner;
- public class Main
- {
- public static void main (String[] args)
- {
- String r;
- String color = "";
- int radius;
- Scanner s = new Scanner (System.in);
- System.out.print ("Enter circle's color : ");
- color = s.nextLine();
- System.out.print ("Enter radius of circle: ");
- r = s.nextLine();
- if (color.isEmpty())
- {
- if (r.isEmpty())
- {
- Circle c = new Circle();
- System.out.println (c.toString());
- System.out.printf ("The circle's area is %.2f and the circumference is %.2f", c.getArea(), c.getCircumference());
- }
- else
- {
- radius = Integer.parseInt(r);
- Circle c = new Circle(radius);
- System.out.println (c.toString());
- System.out.printf ("The circle's area is %.2f and the circumference is %.2f", c.getArea(), c.getCircumference());
- }
- }
- else
- {
- if (r.isEmpty())
- {
- System.out.println ("Jika warna diisi, panjang jari-jari lingkaran juga harus terisi");
- }
- else
- {
- radius = Integer.parseInt(r);
- Circle c = new Circle(radius, color);
- System.out.println (c.toString());
- System.out.printf ("The circle's area is %.2f and the circumference is %.2f", c.getArea(), c.getCircumference());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment