TBD.my

Full Version: [WTA] Switch
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
nak tanya dari master-master semua, aku compile ade 39 error. kt mane salah tu? nk tgk dlm compiler tak reti dan tak faham Fuck That Shit


Code:
import java.util.Scanner;
public class ComputeBMI{  
public static void main(String[] args){
Scanner input = new Scanner(System.in);  
System.out.println(“Enter weight in pounds”);
double weight = input.nextDouble();
System.out.println(“Enter height in inches”);
double height = input.nextDouble();
final double KILOGRAMS_PER_POUND = 0.45359237;
final double METERS_PER_INCH = 0.0254;
double weightInKilograms = weight * KILOGRAMS_PER_POUND;
double heightInMeters = height * METERS_PER_INCH;
double BMI = weightInKilograms / (heightInMeters* heightInMeters);
System.out.println(“Your BMI is %5.3f\n”, bmi);
switch (BMI) {
    if (BMI<16)
    case 1: System.out.println("You are seriously under weight"); break;
    if (BMI<18)
    case 2: System.out.println("You are under weight"); break;
    if (BMI<24)
    case 3: System.out.println("You are normal weight"); break;
    if (BMI<29)
    case 4: System.out.println("You are over weight"); break;
    if (BMI<35)
    case 5: System.out.println("You are seriously over weight"); break;
    if (BMI>35)
    case 6: System.out.println("You are gravely over weight"); break;
}
}
}

error-error Fuck That Shit

Code:
--------------------Configuration: <Default>--------------------
C:\Users\Dell\Documents\ComputeBMI.java:5: error: illegal character: \8220
System.out.println(“Enter weight in pounds”);
                   ^
C:\Users\Dell\Documents\ComputeBMI.java:5: error: ';' expected
System.out.println(“Enter weight in pounds”);
                    ^
C:\Users\Dell\Documents\ComputeBMI.java:5: error: ';' expected
System.out.println(“Enter weight in pounds”);
                                   ^
C:\Users\Dell\Documents\ComputeBMI.java:5: error: illegal character: \8221
System.out.println(“Enter weight in pounds”);
                                          ^
C:\Users\Dell\Documents\ComputeBMI.java:5: error: not a statement
System.out.println(“Enter weight in pounds”);
                                    ^
C:\Users\Dell\Documents\ComputeBMI.java:7: error: illegal character: \8220
System.out.println(“Enter height in inches”);
                   ^
C:\Users\Dell\Documents\ComputeBMI.java:7: error: ';' expected
System.out.println(“Enter height in inches”);
                    ^
C:\Users\Dell\Documents\ComputeBMI.java:7: error: ';' expected
System.out.println(“Enter height in inches”);
                                   ^
C:\Users\Dell\Documents\ComputeBMI.java:7: error: illegal character: \8221
System.out.println(“Enter height in inches”);
                                          ^
C:\Users\Dell\Documents\ComputeBMI.java:7: error: not a statement
System.out.println(“Enter height in inches”);
                                    ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: illegal character: \8220
System.out.println(“Your BMI is %5.3f\n”, bmi);
                   ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: ';' expected
System.out.println(“Your BMI is %5.3f\n”, bmi);
                    ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: ';' expected
System.out.println(“Your BMI is %5.3f\n”, bmi);
                               ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: illegal character: \92
System.out.println(“Your BMI is %5.3f\n”, bmi);
                                     ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: illegal character: \8221
System.out.println(“Your BMI is %5.3f\n”, bmi);
                                       ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: not a statement
System.out.println(“Your BMI is %5.3f\n”, bmi);
                                      ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: not a statement
System.out.println(“Your BMI is %5.3f\n”, bmi);
                                          ^
C:\Users\Dell\Documents\ComputeBMI.java:14: error: ';' expected
System.out.println(“Your BMI is %5.3f\n”, bmi);
                                             ^
C:\Users\Dell\Documents\ComputeBMI.java:16: error: case, default, or '}' expected
    if (BMI<16)
    ^
C:\Users\Dell\Documents\ComputeBMI.java:16: error: case, default, or '}' expected
    if (BMI<16)
       ^
C:\Users\Dell\Documents\ComputeBMI.java:16: error: case, default, or '}' expected
    if (BMI<16)
        ^
C:\Users\Dell\Documents\ComputeBMI.java:16: error: case, default, or '}' expected
    if (BMI<16)
           ^
C:\Users\Dell\Documents\ComputeBMI.java:16: error: case, default, or '}' expected
    if (BMI<16)
            ^
C:\Users\Dell\Documents\ComputeBMI.java:16: error: case, default, or '}' expected
    if (BMI<16)
              ^
C:\Users\Dell\Documents\ComputeBMI.java:19: error: illegal start of expression
    case 2: System.out.println("You are under weight"); break;
    ^
C:\Users\Dell\Documents\ComputeBMI.java:19: error: not a statement
    case 2: System.out.println("You are under weight"); break;
         ^
C:\Users\Dell\Documents\ComputeBMI.java:19: error: ';' expected
    case 2: System.out.println("You are under weight"); break;
          ^
C:\Users\Dell\Documents\ComputeBMI.java:21: error: illegal start of expression
    case 3: System.out.println("You are normal weight"); break;
    ^
C:\Users\Dell\Documents\ComputeBMI.java:21: error: not a statement
    case 3: System.out.println("You are normal weight"); break;
         ^
C:\Users\Dell\Documents\ComputeBMI.java:21: error: ';' expected
    case 3: System.out.println("You are normal weight"); break;
          ^
C:\Users\Dell\Documents\ComputeBMI.java:23: error: illegal start of expression
    case 4: System.out.println("You are over weight"); break;
    ^
C:\Users\Dell\Documents\ComputeBMI.java:23: error: not a statement
    case 4: System.out.println("You are over weight"); break;
         ^
C:\Users\Dell\Documents\ComputeBMI.java:23: error: ';' expected
    case 4: System.out.println("You are over weight"); break;
          ^
C:\Users\Dell\Documents\ComputeBMI.java:25: error: illegal start of expression
    case 5: System.out.println("You are seriously over weight"); break;
    ^
C:\Users\Dell\Documents\ComputeBMI.java:25: error: not a statement
    case 5: System.out.println("You are seriously over weight"); break;
         ^
C:\Users\Dell\Documents\ComputeBMI.java:25: error: ';' expected
    case 5: System.out.println("You are seriously over weight"); break;
          ^
C:\Users\Dell\Documents\ComputeBMI.java:27: error: illegal start of expression
    case 6: System.out.println("You are gravely over weight"); break;
    ^
C:\Users\Dell\Documents\ComputeBMI.java:27: error: not a statement
    case 6: System.out.println("You are gravely over weight"); break;
         ^
C:\Users\Dell\Documents\ComputeBMI.java:27: error: ';' expected
    case 6: System.out.println("You are gravely over weight"); break;
          ^
39 errors

Process completed.
Code:
System.out.println(“Your BMI is %5.3f\n”, bmi);

ko buat dalam java ke c ? Hmm

bukan ke dalam java camni ke

Code:
System.out.println(“Your BMI is ”+bmi);

btw, kenapa input dalam inches ngan pound ??
kenapa x amik input tros dalam kg ngan cm Hmm
java. ntah le, kadang-kadang coding lecturer aku ni fail sikit. Fuck That Shit

(12-01-2013, 11:15 PM)lamki Wrote: [ -> ]
Code:
System.out.println(“Your BMI is %5.3f\n”, bmi);

ko buat dalam java ke c ? Hmm

bukan ke dalam java camni ke

Code:
System.out.println(“Your BMI is ”+bmi);
lagi satu, kenapa pakai switch instead of if,
sbb selalunya BMI xkan dapat accurate value,
and yg paling penting result dia antara dua value contohnya

Code:
A BMI between 18.6 and 24.9 indicates you are at a healthy weight.

jadi guna switch macam xsesuai je...
tp tu pandangan aku je la
lecturer aku suruh tukar dari penggunaan if else kpd switch, sbb tu aku pakai switch. ntahle. terpaksa lah buat utk dptkan markah assignment ;d

(12-01-2013, 11:29 PM)lamki Wrote: [ -> ]lagi satu, kenapa pakai switch instead of if,
sbb selalunya BMI xkan dapat accurate value,
and yg paling penting result dia antara dua value contohnya

Code:
A BMI between 18.6 and 24.9 indicates you are at a healthy weight.

jadi guna switch macam xsesuai je...
tp tu pandangan aku je la
lepas tgk balik boleh je kot...
tp ni cara aku la...ada lg cara lain
ni contoh je...

Spoiler:
Code:
int ind = 0;
    
    if(BMI<18){ind = 1;}
    else if(BMI<18.5){ind = 2;}
    else if(BMI<24.9){ind = 3;}
    else if(BMI<29.9){ind = 4;}
    else {ind = 5;}
    

switch(ind) {
    
    case 1: System.out.println("You are seriously under weight"); break;
    
    case 2: System.out.println("You are under weight"); break;
    
    case 3: System.out.println("You are normal weight"); break;
    
    case 4: System.out.println("You are over weight"); break;
  
    case 5: System.out.println("You are seriously over weight"); break;
}

tQ lamki, coding kau jadi ;d
duduk atas lantai buat, Troll 2

+rape ;d

(12-01-2013, 11:46 PM)lamki Wrote: [ -> ]lepas tgk balik boleh je kot...
tp ni cara aku la...ada lg cara lain
ni contoh je...

Spoiler:
Code:
int ind = 0;
    
    if(BMI<18){ind = 1;}
    else if(BMI<18.5){ind = 2;}
    else if(BMI<24.9){ind = 3;}
    else if(BMI<29.9){ind = 4;}
    else {ind = 5;}
    

switch(ind) {
    
    case 1: System.out.println("You are seriously under weight"); break;
    
    case 2: System.out.println("You are under weight"); break;
    
    case 3: System.out.println("You are normal weight"); break;
    
    case 4: System.out.println("You are over weight"); break;
  
    case 5: System.out.println("You are seriously over weight"); break;
}