Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @(#)kerusi.java
- *
- *
- * @author @ LowKey 2011 hisyamnasir@gmail.com
- * @version 1.00 2011/1/18
- */
- import java.util.Scanner;
- import java.lang.String;
- public class kerusi {
- public static void main(String[] args) {
- Scanner obj = new Scanner(System.in);
- System.out.println("height?");
- double height = obj.nextDouble();
- System.out.println("width?");
- double width = obj.nextDouble();
- System.out.println("length?");
- double length = obj.nextDouble();
- System.out.println("weight?");
- double weight = obj.nextDouble();
- // method
- String type; // declare type
- // this value for height
- // if height >= 0.5 and <=1.5 it will choose Armchair
- if (height >= 0.5 && height <= 1.5) {
- type = "Armchair";
- // if height >= 0.5 and <=1.0 it will choose Bar Stool
- } else if (height >= 1 && height <= 1.0) {
- type = "Bar Stool";
- // if height >= 0.5 and <=1.5 it will choose Bench
- } else if (height >= 0.5 && height <= 1.5) {
- type = "Bench";
- } else {
- type = "Unknown";
- }
- // this value for width
- // if width >= 0.5 and <=1.0 it will choose Armchair
- if (width >= 0.5 && width <= 1.0) {
- type = "Armchair";
- // if width >= 0.14 and <=0.25 it will choose Bar Stool
- } else if (width >= 0.14 && width <= 0.25) {
- type = "Bar Stool";
- // if width >= 1.0 and <=3.0 it will choose Bench
- } else if (width >= 1.0 && width <= 3.0) {
- type = "Bench";
- } else {
- type = "Unknown";
- }
- // this value for length
- // if length >= 0.14 and <=0.25 it will choose Armchair
- if (length >= 0.14 && length <= 0.25) {
- type = "Armchair";
- // if length >= 0.14 and <=0.25 it will choose Bar Stool
- } else if (length >= 0.14 && length <= 0.25) {
- type = "Bar Stool";
- // if length >= 0.14 and <=0.25 it will choose Bench
- } else if (length >= 0.14 && length <= 0.25) {
- type = "Bench";
- } else {
- type = "Unknown";
- }
- // this value for weight
- // if weight >= 5 and <=18 it will choose Armchair
- if (weight >= 5 && weight <= 18) {
- type = "Armchair";
- // if weight >= 3.0 and <=7 it will choose Bar Stool
- } else if (weight >= 3.0 && weight <= 7) {
- type = "Bar Stool";
- // if weight >= 10 and <=50 it will choose Bench
- } else if (weight >= 10 && weight <= 50) {
- type = "Bench";
- } else {
- type = "Unknown";
- }
- System.out.println("Type of Kerusi = " + type);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement