Results 1 to 12 of 12
  1. #1
    besweeet is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default Using switches...

    Here's my code so far:
    Java Code:
    import java.io.*;
    import java.util.*;
    
    /*
     * A QUICK NOTE!!!!! For the scores/elements/averages, the first number represents the skater number, the second number
     * represents the element/category number, and the third represents the score number (score115, etc).
    */
    
    public class lab4
    {
      public static void main(String [] args) throws FileNotFoundException
      {
        // I/O Stuff
        Scanner inFile1 = new Scanner(new FileReader("scores1.txt"));
        Scanner inFile2 = new Scanner(new FileReader("scores2.txt"));
        Scanner inFile3 = new Scanner(new FileReader("scores3.txt"));
        
        // Declaring base values
        double Lz3 = 6.0;
        double A2 = 3.5;
        double FSSp4 = 3.0;
        double CCoSp2 = 2.5;
        
        // [SKATER 1] First name, last name, gender, country, short/long
        String firstName1;
        String lastName1;
        String genderBefore1; // All going to be female...
        char gender1;
        String countryBefore1;
        char country1;
        String shortLong1; // All going to be short...
        
        firstName1 = inFile1.next();
        lastName1 = inFile1.next();
        genderBefore1 = inFile1.next();
        gender1 = genderBefore1.charAt(0);
        countryBefore1 = inFile1.next();
        country1 = countryBefore1.charAt(0);
        shortLong1 = inFile1.next();
        
        System.out.println("[1/3] First name: "+firstName1);
        System.out.println("[1/3] Last name: "+lastName1);
        System.out.println("[1/3] M/F? "+gender1);
        System.out.println("[1/3] Country: "+country1);
        System.out.println("[1/3] Short/long? "+shortLong1+"\n");
        
        // [SKATER 2] First name, last name, gender, country, short/long
        String firstName2;
        String lastName2;
        String genderBefore2; // All [eventually] going to be female...
        char gender2;
        String countryBefore2;
        char country2;
        String shortLong2; // All [eventually] going to be short...
        
        firstName2 = inFile2.next();
        lastName2 = inFile2.next();
        genderBefore2 = inFile2.next();
        gender2 = genderBefore2.charAt(0);
        countryBefore2 = inFile2.next();
        country2 = countryBefore2.charAt(0);
        shortLong2 = inFile2.next();
        
        System.out.println("[2/3] First name: "+firstName2);
        System.out.println("[2/3] Last name: "+lastName2);
        System.out.println("[2/3] M/F? "+gender2);
        System.out.println("[2/3] Country: "+country2);
        System.out.println("[2/3] Short/long? "+shortLong2+"\n");
        
        // [SKATER 3] First name, last name, gender, country, short/long
        String firstName3;
        String lastName3;
        String genderBefore3; // All [eventually] going to be female...
        char gender3;
        String countryBefore3;
        char country3;
        String shortLong3; // All [eventually] going to be short...
        
        firstName3 = inFile3.next();
        lastName3 = inFile3.next();
        genderBefore3 = inFile3.next();
        gender3 = genderBefore3.charAt(0);
        countryBefore3 = inFile3.next();
        country3 = countryBefore3.charAt(0);
        shortLong3 = inFile3.next();
        
        System.out.println("[3/3] First name: "+firstName3);
        System.out.println("[3/3] Last name: "+lastName3);
        System.out.println("[3/3] M/F? "+gender3);
        System.out.println("[3/3] Country: "+country3);
        System.out.println("[3/3] Short/long? "+shortLong3+"\n");
        
        // [SKATER 1, ELEMENT 1] GOE
        String element11 = inFile1.next();
        double score111 = inFile1.nextDouble();
        double score112 = inFile1.nextDouble();
        double score113 = inFile1.nextDouble();
        double score114 = inFile1.nextDouble();
        double score115 = inFile1.nextDouble();
        double average11 = (((score111 + score112 + score113 + score114 + score115)/5)+Lz3);
        
        System.out.println("[1/3 EL1] Element: "+element11);
        System.out.println("[1/3 EL1] Score 1: "+score111);
        System.out.println("[1/3 EL1] Score 2: "+score112);
        System.out.println("[1/3 EL1] Score 3: "+score113);
        System.out.println("[1/3 EL1] Score 4: "+score114);
        System.out.println("[1/3 EL1] Score 5: "+score115);
        System.out.println("[1/3 EL1] Average Score: "+average11+"\n");
        
        // [SKATER 1, ELEMENT 2] GOE
        String element12 = inFile1.next();
        double score121 = inFile1.nextDouble();
        double score122 = inFile1.nextDouble();
        double score123 = inFile1.nextDouble();
        double score124 = inFile1.nextDouble();
        double score125 = inFile1.nextDouble();
        double average12 = (((score121 + score122 + score123 + score124 + score125)/5)+A2);
        
        System.out.println("[1/3 EL2] Element: "+element12);
        System.out.println("[1/3 EL2] Score 1: "+score121);
        System.out.println("[1/3 EL2] Score 2: "+score122);
        System.out.println("[1/3 EL2] Score 3: "+score123);
        System.out.println("[1/3 EL2] Score 4: "+score124);
        System.out.println("[1/3 EL2] Score 5: "+score125);
        System.out.println("[1/3 EL2] Average Score: "+average12+"\n");
        
        // [SKATER 1, ELEMENT 3] GOE
        String element13 = inFile1.next();
        double score131 = inFile1.nextDouble();
        double score132 = inFile1.nextDouble();
        double score133 = inFile1.nextDouble();
        double score134 = inFile1.nextDouble();
        double score135 = inFile1.nextDouble();
        double average13 = (((score131 + score132 + score133 + score134 + score135)/5)+FSSp4);
        
        System.out.println("[1/3 EL3] Element: "+element13);
        System.out.println("[1/3 EL3] Score 1: "+score131);
        System.out.println("[1/3 EL3] Score 2: "+score132);
        System.out.println("[1/3 EL3] Score 3: "+score133);
        System.out.println("[1/3 EL3] Score 4: "+score134);
        System.out.println("[1/3 EL3] Score 5: "+score135);
        System.out.println("[1/3 EL3] Average Score: "+average13+"\n");
        
        // [SKATER 1, ELEMENT 4] GOE
        String element14 = inFile1.next();
        double score141 = inFile1.nextDouble();
        double score142 = inFile1.nextDouble();
        double score143 = inFile1.nextDouble();
        double score144 = inFile1.nextDouble();
        double score145 = inFile1.nextDouble();
        double average14 = (((score141 + score142 + score143 + score144 + score145)/5)+CCoSp2);
        
        System.out.println("[1/3 EL4] Element: "+element14);
        System.out.println("[1/3 EL4] Score 1: "+score141);
        System.out.println("[1/3 EL4] Score 2: "+score142);
        System.out.println("[1/3 EL4] Score 3: "+score143);
        System.out.println("[1/3 EL4] Score 4: "+score144);
        System.out.println("[1/3 EL4] Score 5: "+score145);
        System.out.println("[1/3 EL4] Average Score: "+average14+"\n");
        
        // [SKATER 2, ELEMENT 1] GOE
        String element21 = inFile2.next();
        double score211 = inFile2.nextDouble();
        double score212 = inFile2.nextDouble();
        double score213 = inFile2.nextDouble();
        double score214 = inFile2.nextDouble();
        double score215 = inFile2.nextDouble();
        double average21 = (((score211 + score212 + score213 + score214 + score215)/5)+Lz3);
        
        System.out.println("[2/3 EL1] Element: "+element21);
        System.out.println("[2/3 EL1] Score 1: "+score211);
        System.out.println("[2/3 EL1] Score 2: "+score212);
        System.out.println("[2/3 EL1] Score 3: "+score213);
        System.out.println("[2/3 EL1] Score 4: "+score214);
        System.out.println("[2/3 EL1] Score 5: "+score215);
        System.out.println("[2/3 EL1] Average Score: "+average21+"\n");
        
        // [SKATER 2, ELEMENT 2] GOE
        String element22 = inFile2.next();
        double score221 = inFile2.nextDouble();
        double score222 = inFile2.nextDouble();
        double score223 = inFile2.nextDouble();
        double score224 = inFile2.nextDouble();
        double score225 = inFile2.nextDouble();
        double average22 = (((score221 + score222 + score223 + score224 + score225)/5)+A2);
        
        System.out.println("[2/3 EL2] Element: "+element22);
        System.out.println("[2/3 EL2] Score 1: "+score221);
        System.out.println("[2/3 EL2] Score 2: "+score222);
        System.out.println("[2/3 EL2] Score 3: "+score223);
        System.out.println("[2/3 EL2] Score 4: "+score224);
        System.out.println("[2/3 EL2] Score 5: "+score225);
        System.out.println("[2/3 EL2] Average Score: "+average22+"\n");
        
        // [SKATER 2, ELEMENT 3] GOE
        String element23 = inFile2.next();
        double score231 = inFile2.nextDouble();
        double score232 = inFile2.nextDouble();
        double score233 = inFile2.nextDouble();
        double score234 = inFile2.nextDouble();
        double score235 = inFile2.nextDouble();
        double average23 = (((score231 + score232 + score233 + score234 + score235)/5)+FSSp4);
        
        System.out.println("[2/3 EL3] Element: "+element23);
        System.out.println("[2/3 EL3] Score 1: "+score231);
        System.out.println("[2/3 EL3] Score 2: "+score232);
        System.out.println("[2/3 EL3] Score 3: "+score233);
        System.out.println("[2/3 EL3] Score 4: "+score234);
        System.out.println("[2/3 EL3] Score 5: "+score235);
        System.out.println("[2/3 EL3] Average Score: "+average23+"\n");
        
        // [SKATER 2, ELEMENT 4] GOE
        String element24 = inFile2.next();
        double score241 = inFile2.nextDouble();
        double score242 = inFile2.nextDouble();
        double score243 = inFile2.nextDouble();
        double score244 = inFile2.nextDouble();
        double score245 = inFile2.nextDouble();
        double average24 = (((score241 + score242 + score243 + score244 + score245)/5)+CCoSp2);
        
        System.out.println("[2/3 EL4] Element: "+element24);
        System.out.println("[2/3 EL4] Score 1: "+score241);
        System.out.println("[2/3 EL4] Score 2: "+score242);
        System.out.println("[2/3 EL4] Score 3: "+score243);
        System.out.println("[2/3 EL4] Score 4: "+score244);
        System.out.println("[2/3 EL4] Score 5: "+score245);
        System.out.println("[2/3 EL4] Average Score: "+average24+"\n");
        
        // [SKATER 3, ELEMENT 1] GOE
        String element31 = inFile3.next();
        double score311 = inFile3.nextDouble();
        double score312 = inFile3.nextDouble();
        double score313 = inFile3.nextDouble();
        double score314 = inFile3.nextDouble();
        double score315 = inFile3.nextDouble();
        double average31 = (((score311 + score312 + score313 + score314 + score315)/5)+Lz3);
        
        System.out.println("[3/3 EL1] Element: "+element31);
        System.out.println("[3/3 EL1] Score 1: "+score311);
        System.out.println("[3/3 EL1] Score 2: "+score312);
        System.out.println("[3/3 EL1] Score 3: "+score313);
        System.out.println("[3/3 EL1] Score 4: "+score314);
        System.out.println("[3/3 EL1] Score 5: "+score315);
        System.out.println("[3/3 EL1] Average Score: "+average31+"\n");
        
        // [SKATER 3, ELEMENT 2] GOE
        String element32 = inFile3.next();
        double score321 = inFile3.nextDouble();
        double score322 = inFile3.nextDouble();
        double score323 = inFile3.nextDouble();
        double score324 = inFile3.nextDouble();
        double score325 = inFile3.nextDouble();
        double average32 = (((score321 + score322 + score323 + score324 + score325)/5)+A2);
        
        System.out.println("[3/3 EL2] Element: "+element32);
        System.out.println("[3/3 EL2] Score 1: "+score321);
        System.out.println("[3/3 EL2] Score 2: "+score322);
        System.out.println("[3/3 EL2] Score 3: "+score323);
        System.out.println("[3/3 EL2] Score 4: "+score324);
        System.out.println("[3/3 EL2] Score 5: "+score325);
        System.out.println("[3/3 EL2] Average Score: "+average32+"\n");
        
        // [SKATER 3, ELEMENT 3] GOE
        String element33 = inFile3.next();
        double score331 = inFile3.nextDouble();
        double score332 = inFile3.nextDouble();
        double score333 = inFile3.nextDouble();
        double score334 = inFile3.nextDouble();
        double score335 = inFile3.nextDouble();
        double average33 = (((score331 + score332 + score333 + score334 + score335)/5)+FSSp4);
        
        System.out.println("[3/3 EL3] Element: "+element33);
        System.out.println("[3/3 EL3] Score 1: "+score331);
        System.out.println("[3/3 EL3] Score 2: "+score332);
        System.out.println("[3/3 EL3] Score 3: "+score333);
        System.out.println("[3/3 EL3] Score 4: "+score334);
        System.out.println("[3/3 EL3] Score 5: "+score335);
        System.out.println("[3/3 EL3] Average Score: "+average33+"\n");
        
        // [SKATER 3, ELEMENT 4] GOE
        String element34 = inFile3.next();
        double score341 = inFile3.nextDouble();
        double score342 = inFile3.nextDouble();
        double score343 = inFile3.nextDouble();
        double score344 = inFile3.nextDouble();
        double score345 = inFile3.nextDouble();
        double average34 = (((score341 + score342 + score343 + score344 + score345)/5)+CCoSp2);
        
        System.out.println("[3/3 EL4] Element: "+element34);
        System.out.println("[3/3 EL4] Score 1: "+score341);
        System.out.println("[3/3 EL4] Score 2: "+score342);
        System.out.println("[3/3 EL4] Score 3: "+score343);
        System.out.println("[3/3 EL4] Score 4: "+score344);
        System.out.println("[3/3 EL4] Score 5: "+score345);
        System.out.println("[3/3 EL4] Average Score: "+average34+"\n");
        
        // Total scores
        double totalScore1 = average11+average12+average13+average14;
        double totalScore2 = average21+average22+average23+average24;
        double totalScore3 = average31+average32+average33+average34;
        
        System.out.println("Skater 1 total: "+totalScore1);
        System.out.println("Skater 2 total: "+totalScore2);
        System.out.println("Skater 3 total: "+totalScore3+"\n");
        
        // [SKATER 1, COMPONENT 1] Raw scores
        String component11 = inFile1.next();
        double component111 = inFile1.nextDouble();
        double component112 = inFile1.nextDouble();
        double component113 = inFile1.nextDouble();
        double component114 = inFile1.nextDouble();
        double component115 = inFile1.nextDouble();
        double averageRaw11 = ((component111+component112+component113+component114+component115)/5);
        
        System.out.println("[1/3 COMP1] Component: "+component11);
        System.out.println("[1/3 COMP1] Raw score 1: "+component111);
        System.out.println("[1/3 COMP1] Raw score 2: "+component112);
        System.out.println("[1/3 COMP1] Raw score 3: "+component113);
        System.out.println("[1/3 COMP1] Raw score 4: "+component114);
        System.out.println("[1/3 COMP1] Raw score 5: "+component115);
        System.out.println("[1/3 COMP1] Average Raw Score: "+averageRaw11+"\n");
        
        // [SKATER 1, COMPONENT 2] Raw scores
        String component12 = inFile1.next();
        double component121 = inFile1.nextDouble();
        double component122 = inFile1.nextDouble();
        double component123 = inFile1.nextDouble();
        double component124 = inFile1.nextDouble();
        double component125 = inFile1.nextDouble();
        double averageRaw12 = ((component121+component122+component123+component124+component125)/5);
        
        System.out.println("[1/3 COMP2] Component: "+component12);
        System.out.println("[1/3 COMP2] Raw score 1: "+component121);
        System.out.println("[1/3 COMP2] Raw score 2: "+component122);
        System.out.println("[1/3 COMP2] Raw score 3: "+component123);
        System.out.println("[1/3 COMP2] Raw score 4: "+component124);
        System.out.println("[1/3 COMP2] Raw score 5: "+component125);
        System.out.println("[1/3 COMP2] Average Raw Score: "+averageRaw12+"\n");
        
        // [SKATER 1, COMPONENT 3] Raw scores
        String component13 = inFile1.next();
        double component131 = inFile1.nextDouble();
        double component132 = inFile1.nextDouble();
        double component133 = inFile1.nextDouble();
        double component134 = inFile1.nextDouble();
        double component135 = inFile1.nextDouble();
        double averageRaw13 = ((component131+component132+component133+component134+component135)/5);
        
        System.out.println("[1/3 COMP3] Component: "+component13);
        System.out.println("[1/3 COMP3] Raw score 1: "+component131);
        System.out.println("[1/3 COMP3] Raw score 2: "+component132);
        System.out.println("[1/3 COMP3] Raw score 3: "+component133);
        System.out.println("[1/3 COMP3] Raw score 4: "+component134);
        System.out.println("[1/3 COMP3] Raw score 5: "+component135);
        System.out.println("[1/3 COMP3] Average Raw Score: "+averageRaw13+"\n");
        
        // [SKATER 1, COMPONENT 4] Raw scores
        String component14 = inFile1.next();
        double component141 = inFile1.nextDouble();
        double component142 = inFile1.nextDouble();
        double component143 = inFile1.nextDouble();
        double component144 = inFile1.nextDouble();
        double component145 = inFile1.nextDouble();
        double averageRaw14 = ((component141+component142+component143+component144+component145)/5);
        
        System.out.println("[1/3 COMP4] Component: "+component14);
        System.out.println("[1/3 COMP4] Raw score 1: "+component141);
        System.out.println("[1/3 COMP4] Raw score 2: "+component142);
        System.out.println("[1/3 COMP4] Raw score 3: "+component143);
        System.out.println("[1/3 COMP4] Raw score 4: "+component144);
        System.out.println("[1/3 COMP4] Raw score 5: "+component145);
        System.out.println("[1/3 COMP4] Average Raw Score: "+averageRaw14+"\n");
        
        // [SKATER 2, COMPONENT 1] Raw scores
        String component21 = inFile2.next();
        double component211 = inFile2.nextDouble();
        double component212 = inFile2.nextDouble();
        double component213 = inFile2.nextDouble();
        double component214 = inFile2.nextDouble();
        double component215 = inFile2.nextDouble();
        double averageRaw21 = ((component211+component212+component213+component214+component215)/5);
        
        System.out.println("[2/3 COMP1] Component: "+component21);
        System.out.println("[2/3 COMP1] Raw score 1: "+component211);
        System.out.println("[2/3 COMP1] Raw score 2: "+component212);
        System.out.println("[2/3 COMP1] Raw score 3: "+component213);
        System.out.println("[2/3 COMP1] Raw score 4: "+component214);
        System.out.println("[2/3 COMP1] Raw score 5: "+component215);
        System.out.println("[2/3 COMP1] Average Raw Score: "+averageRaw21+"\n");
        
        // [SKATER 2, COMPONENT 2] Raw scores
        String component22 = inFile2.next();
        double component221 = inFile2.nextDouble();
        double component222 = inFile2.nextDouble();
        double component223 = inFile2.nextDouble();
        double component224 = inFile2.nextDouble();
        double component225 = inFile2.nextDouble();
        double averageRaw22 = ((component221+component222+component223+component224+component225)/5);
        
        System.out.println("[2/3 COMP2] Component: "+component22);
        System.out.println("[2/3 COMP2] Raw score 1: "+component221);
        System.out.println("[2/3 COMP2] Raw score 2: "+component222);
        System.out.println("[2/3 COMP2] Raw score 3: "+component223);
        System.out.println("[2/3 COMP2] Raw score 4: "+component224);
        System.out.println("[2/3 COMP2] Raw score 5: "+component225);
        System.out.println("[2/3 COMP2] Average Raw Score: "+averageRaw22+"\n");
        
        // [SKATER 2, COMPONENT 3] Raw scores
        String component23 = inFile2.next();
        double component231 = inFile2.nextDouble();
        double component232 = inFile2.nextDouble();
        double component233 = inFile2.nextDouble();
        double component234 = inFile2.nextDouble();
        double component235 = inFile2.nextDouble();
        double averageRaw23 = ((component231+component232+component233+component234+component235)/5);
        
        System.out.println("[2/3 COMP3] Component: "+component23);
        System.out.println("[2/3 COMP3] Raw score 1: "+component231);
        System.out.println("[2/3 COMP3] Raw score 2: "+component232);
        System.out.println("[2/3 COMP3] Raw score 3: "+component233);
        System.out.println("[2/3 COMP3] Raw score 4: "+component234);
        System.out.println("[2/3 COMP3] Raw score 5: "+component235);
        System.out.println("[2/3 COMP3] Average Raw Score: "+averageRaw23+"\n");
        
        // [SKATER 2, COMPONENT 4] Raw scores
        String component24 = inFile2.next();
        double component241 = inFile2.nextDouble();
        double component242 = inFile2.nextDouble();
        double component243 = inFile2.nextDouble();
        double component244 = inFile2.nextDouble();
        double component245 = inFile2.nextDouble();
        double averageRaw24 = ((component241+component242+component243+component244+component245)/5);
        
        System.out.println("[2/3 COMP4] Component: "+component24);
        System.out.println("[2/3 COMP4] Raw score 1: "+component241);
        System.out.println("[2/3 COMP4] Raw score 2: "+component242);
        System.out.println("[2/3 COMP4] Raw score 3: "+component243);
        System.out.println("[2/3 COMP4] Raw score 4: "+component244);
        System.out.println("[2/3 COMP4] Raw score 5: "+component245);
        System.out.println("[2/3 COMP4] Average Raw Score: "+averageRaw24+"\n");
        
        // [SKATER 3, COMPONENT 1] Raw scores
        String component31 = inFile3.next();
        double component311 = inFile3.nextDouble();
        double component312 = inFile3.nextDouble();
        double component313 = inFile3.nextDouble();
        double component314 = inFile3.nextDouble();
        double component315 = inFile3.nextDouble();
        double averageRaw31 = ((component311+component312+component313+component314+component315)/5);
        
        System.out.println("[3/3 COMP1] Component: "+component31);
        System.out.println("[3/3 COMP1] Raw score 1: "+component311);
        System.out.println("[3/3 COMP1] Raw score 2: "+component312);
        System.out.println("[3/3 COMP1] Raw score 3: "+component313);
        System.out.println("[3/3 COMP1] Raw score 4: "+component314);
        System.out.println("[3/3 COMP1] Raw score 5: "+component315);
        System.out.println("[3/3 COMP1] Average Raw Score: "+averageRaw31+"\n");
        
        // [SKATER 3, COMPONENT 2] Raw scores
        String component32 = inFile3.next();
        double component321 = inFile3.nextDouble();
        double component322 = inFile3.nextDouble();
        double component323 = inFile3.nextDouble();
        double component324 = inFile3.nextDouble();
        double component325 = inFile3.nextDouble();
        double averageRaw32 = ((component321+component322+component323+component324+component325)/5);
        
        System.out.println("[3/3 COMP2] Component: "+component32);
        System.out.println("[3/3 COMP2] Raw score 1: "+component321);
        System.out.println("[3/3 COMP2] Raw score 2: "+component322);
        System.out.println("[3/3 COMP2] Raw score 3: "+component323);
        System.out.println("[3/3 COMP2] Raw score 4: "+component324);
        System.out.println("[3/3 COMP2] Raw score 5: "+component325);
        System.out.println("[3/3 COMP2] Average Raw Score: "+averageRaw32+"\n");
        
        // [SKATER 3, COMPONENT 3] Raw scores
        String component33 = inFile3.next();
        double component331 = inFile3.nextDouble();
        double component332 = inFile3.nextDouble();
        double component333 = inFile3.nextDouble();
        double component334 = inFile3.nextDouble();
        double component335 = inFile3.nextDouble();
        double averageRaw33 = ((component331+component332+component333+component334+component335)/5);
        
        System.out.println("[3/3 COMP3] Component: "+component33);
        System.out.println("[3/3 COMP3] Raw score 1: "+component331);
        System.out.println("[3/3 COMP3] Raw score 2: "+component332);
        System.out.println("[3/3 COMP3] Raw score 3: "+component333);
        System.out.println("[3/3 COMP3] Raw score 4: "+component334);
        System.out.println("[3/3 COMP3] Raw score 5: "+component335);
        System.out.println("[3/3 COMP3] Average Raw Score: "+averageRaw33+"\n");
        
        // [SKATER 3, COMPONENT 4] Raw scores
        String component34 = inFile3.next();
        double component341 = inFile3.nextDouble();
        double component342 = inFile3.nextDouble();
        double component343 = inFile3.nextDouble();
        double component344 = inFile3.nextDouble();
        double component345 = inFile3.nextDouble();
        double averageRaw34 = ((component341+component342+component343+component344+component345)/5);
        
        System.out.println("[3/3 COMP4] Component: "+component34);
        System.out.println("[3/3 COMP4] Raw score 1: "+component341);
        System.out.println("[3/3 COMP4] Raw score 2: "+component342);
        System.out.println("[3/3 COMP4] Raw score 3: "+component343);
        System.out.println("[3/3 COMP4] Raw score 4: "+component344);
        System.out.println("[3/3 COMP4] Raw score 5: "+component345);
        System.out.println("[3/3 COMP4] Average Raw Score: "+averageRaw34+"\n");
        
        // Total of all raw scores
        double s1Raw = averageRaw11+averageRaw12+averageRaw13+averageRaw14;
        double s2Raw = averageRaw21+averageRaw22+averageRaw23+averageRaw24;
        double s3Raw = averageRaw31+averageRaw32+averageRaw33+averageRaw34;
        
        System.out.println("Skater 1 raw: "+s1Raw);
        System.out.println("Skater 2 raw: "+s2Raw);
        System.out.println("Skater 3 raw: "+s3Raw+"\n");
        
        // Program score
        double s1Prog = s1Raw * 0.8;
        double s2Prog = s2Raw * 0.8;
        double s3Prog = s3Raw * 0.8;
        
        System.out.println("Skater 1 program score: "+s1Prog);
        System.out.println("Skater 2 program score: "+s2Prog);
        System.out.println("Skater 3 program score: "+s3Prog+"\n");
        
        // OVERALL/FINAL score
        double s1Overall = s1Prog+totalScore1;
        double s2Overall = s2Prog+totalScore2;
        double s3Overall = s3Prog+totalScore3;
        
        System.out.println("Skater 1 OVERALL score: "+s1Overall);
        System.out.println("Skater 2 OVERALL score: "+s2Overall);
        System.out.println("Skater 3 OVERALL score: "+s3Overall+"\n");
        
        // Medal giveaway
        System.out.println(""+firstName1+" "+lastName1+" [skater 1] receives the silver medal!");
        System.out.println(""+firstName2+" "+lastName2+" [skater 2] receives the gold medal!");
        System.out.println(""+firstName3+" "+lastName3+" [skater 3] receives the bronze medal!\n");
        
        // If stuff/medal display
        int goldS1 = 0;
        int silverS1 = 0;
        int bronzeS1 = 0;
        
        int goldS2 = 1;
        int silverS2 = 1;
        int bronzeS2 = 1;
        
        int goldS3 = 2;
        int silverS3 = 2;
        int bronzeS3 = 2;
        
        /*
        if(s1Overall>s2Overall && s1Overall>s3Overall)
        {
         System.out.println(""+firstName1+" "+lastName1+" [skater 1] receives the "+gold+++" medal!");
        }
        else if(s2Overall>s1Overall && s2Overall>s3Overall)
        {
          System.out.println(""+firstName2+" "+lastName2+" [skater 2] receives the "+silver+++" medal!");
        }
        else
        {
          System.out.println(""+firstName3+" "+lastName3+" [skater 3] receives the "+bronze+++" medal!");
        }
        */
                
        // Closing the files
        inFile1.close();
        inFile2.close();
        inFile3.close();
      }
    }
    Here's the first input file:
    Java Code:
    Mao Asada
    Female
    Japan
    short
    3Lz
    1.0
    1.0
    2.0
    1.0
    3.0
    2A
    1.0
    1.0
    1.0
    1.0
    1.0
    FSSp4
    1.0
    0.0
    0.0
    1.0
    1.0
    CCoSp2
    2.0
    1.0
    0.0
    1.0
    1.0
    Transition
    6.75
    5.75
    6.5
    6.75
    6.75
    Performance
    6.75
    6.5
    6.75
    6.5
    7.0
    Choreography
    7.25
    6.25
    6.75
    6.75
    6.75
    Interpretation
    7.0
    6.25
    6.5
    6.5
    7.0
    Here's the second input file:
    Java Code:
    Mary Jane
    Female
    USA
    short
    3Lz
    1.0
    1.0
    2.0
    1.0
    3.0
    2A
    2.0
    2.0
    2.0
    2.0
    2.0
    FSSp4
    2.0
    1.0
    1.0
    2.0
    2.0
    CCoSp2
    3.0
    2.0
    1.0
    2.0
    2.0
    Transition
    6.75
    5.75
    6.5
    6.75
    6.75
    Performance
    6.75
    6.5
    6.75
    6.5
    7.0
    Choreography
    8.25
    7.25
    7.75
    7.75
    7.75
    Interpretation
    8.0
    7.25
    7.5
    7.5
    8.0
    And here's the third:
    Java Code:
    Sally Shore
    Female
    Canada
    short
    3Lz
    1.0
    1.0
    2.0
    1.0
    3.0
    2A
    3.0
    3.0
    3.0
    3.0
    3.0
    FSSp4
    3.0
    2.0
    2.0
    3.0
    3.0
    CCoSp2
    4.0
    3.0
    2.0
    3.0
    3.0
    Transition
    4.75
    3.75
    4.5
    4.75
    6.75
    Performance
    4.75
    4.5
    4.75
    4.5
    5.0
    Choreography
    5.25
    4.25
    4.75
    4.75
    4.75
    Interpretation
    5.0
    4.25
    4.5
    4.5
    5.0
    So:
    "Using a switch-statement to test the home country for each skater, update the appropriate country's medal count for gold, silver, and bronze medals. Included in your switch statement should be statement(s) to display the complete name of the country and the total number of medals of each type. You may choose an initial quantity of medals, or set them all to 0 prior to adding the medals from the 3 skaters represented in the data file."

    I don't see how a switch-statement could be used here... The TA tried explaining it to me, but I just don't understand it.

    ALSO: We're using loops for this program in the next assignment. For now, we have to do everything the long way.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Huh, is your TA written this code or you? For me this is real mess-up, the way code is organized. 100s of lines in a single method, in main.

    Anyway, regarding your question. I cannot see any switch-case statement in your code. Is that TA ask you to implement this in switch-case? Without such thing how can TA explain that. May be he's given the wrong code segment. Check with him.

  3. #3
    besweeet is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    No, that's mine. Just following directions.

    I thought I edited the first post with my switch:
    Java Code:
        switch(country1)
        {
          case 'J':
            silverS1++;
            System.out.println(""+countryBefore1);
            System.out.println("=====");
            System.out.println("Gold: "+goldS1);
            System.out.println("Silver: "+silverS1);
            System.out.println("Bronze: "+bronzeS1+"\n");
        }
        switch(country2)
        {
          case 'U':
            goldS2++;
            System.out.println(""+countryBefore2);
            System.out.println("===");
            System.out.println("Gold: "+goldS2);
            System.out.println("Silver: "+silverS2);
            System.out.println("Bronze: "+bronzeS2+"\n");
        }
        switch(country3)
        {
          case 'C':
            bronzeS3++;
            System.out.println(""+countryBefore3);
            System.out.println("======");
            System.out.println("Gold: "+goldS3);
            System.out.println("Silver: "+silverS3);
            System.out.println("Bronze: "+bronzeS3+"\n");
        }
    For the sake of this assignment, I guess I did what the question asked, right? ;)

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Seems okay. Did you run the code? And check that the correct result can be retrieve from that.

  5. #5
    besweeet is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    Yup, seems to accomplish the intended goal :). Thanks.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  7. #7
    besweeet is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    I have a new question for this same project. How would I implement loops into it?

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    What loop on where? Commonly in any programming language, several looping statements (for, while, do-while), know as control flow statements.

    So what you want to implement using that?

  9. #9
    besweeet is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    Instead of all the repetitive lines, just use the proper loop variable.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    To use loops in your code have to do lots of things. Because your code is real mess-up.

    First of all try to understand the following code segment, I hope you know that. It's very simple one.

    Java Code:
    for(int index = 0; index < 10; index++) {
       System.out.println(index);
    }
    My question is what's the major different with that code and your application?

  11. #11
    besweeet is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    That one will automatically repeat what's inside of the for loop 10 times. I understand how to use and make loops, but I just don't see how it would fit into my application... Well I sort of have an idea. I'll start on it later today and let you know how it is ;).

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. help with switches
    By spots of fire in forum New To Java
    Replies: 1
    Last Post: 01-23-2010, 10:02 PM
  2. how to convert from switches to methods
    By peacehope in forum New To Java
    Replies: 4
    Last Post: 03-27-2009, 01:33 AM
  3. Help with switches
    By Daniel in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 09:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •