Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WTA] Switch
12-01-2013, 10:37 PM, (This post was last modified: 12-01-2013, 10:43 PM by marblesbubbles.)
Post: #1
Bug  [WTA] Switch
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.
[Image: gamers%2Bpassion.jpg]
Reply
12-01-2013, 11:15 PM, (This post was last modified: 12-01-2013, 11:20 PM by lamki.)
Post: #2
RE: [WTA] Switch
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
Revenge 101 :
Spoiler:

1.Pee in plate
2.Freeze the pee(in 1.)
3.Slide frozen 'pee disc' under the victim's door(room or house, any will do)
4.The pee disc will now melt.
5.???
6.Profit

Hmm
Reply
12-01-2013, 11:18 PM,
Post: #3
RE: [WTA] Switch
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);
[Image: gamers%2Bpassion.jpg]
Reply
12-01-2013, 11:29 PM,
Post: #4
RE: [WTA] Switch
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
Revenge 101 :
Spoiler:

1.Pee in plate
2.Freeze the pee(in 1.)
3.Slide frozen 'pee disc' under the victim's door(room or house, any will do)
4.The pee disc will now melt.
5.???
6.Profit

Hmm
Reply
12-01-2013, 11:36 PM,
Post: #5
RE: [WTA] Switch
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
[Image: gamers%2Bpassion.jpg]
Reply
12-01-2013, 11:46 PM,
Post: #6
RE: [WTA] Switch
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;
}

Revenge 101 :
Spoiler:

1.Pee in plate
2.Freeze the pee(in 1.)
3.Slide frozen 'pee disc' under the victim's door(room or house, any will do)
4.The pee disc will now melt.
5.???
6.Profit

Hmm
Reply
13-01-2013, 06:30 PM,
Post: #7
RE: [WTA] Switch
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;
}

[Image: gamers%2Bpassion.jpg]
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
Exclamation Switch Case + String ??? 127001 6 1,225 13-09-2010, 02:14 AM
Last Post: aa
  [help]Switch case + Char ??? 127001 4 927 21-08-2010, 11:05 AM
Last Post: 127001

Forum Jump: