HELP SOS static void methods. and methods that pass parameters

Discussion in 'Java' started by lew09302500, Jun 5, 2011.

  1. lew09302500

    lew09302500 New Member

    Joined:
    Jun 5, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    :crazy: I need some help with these two parts of my assignment, Ive managed to do the first part can someone modify my code to reflect the next two parts I have no Idea what to do, the book that we have been issued is useless.


    b. Modify the program by demonstrating the use of static void methods. Your methods do not require to pass parameters, that is, use class variables (global variables). save as partB_b.java
    (10 marks)
    c. Demonstrate the use of methods that pass parameters. Create at least 2 methods in addition to the main() method. This program must have local variables. save as partB_c.java
    (10 marks)


    Code:
    // Template for java programs
    import java.text.*;
    import java.util.*;
    public class partB_b
    {
       // main method
       public static void main( String [] args)
       {
        int i,NumPatientsBasic,NumPatientsFlu,NumAfterHoursBasic,NumAfterHoursFlu,After=0,normal=0,TotFlu=0,TotBas=0;
        String dayofWeek[] ={"monday","Tuesday","Wednesday","Thursday","Friday"};
        Double FeeFlu=5.00,TotalFeeFlu=0.00,FeeBasic=15.00,TotalDaily=0.00,TotalFeeBasic=0.00,AHoursFlu=0.00,AHoursBasic=0.00,TotalWeeklyRevenue=0.00;
        Double Sum =0.00;
        
        
        Scanner sc = new Scanner(System.in);
         
        
         for(i=0; i<5;i++){
        
         
         System.out.print("\nPlease enter Number of Patients Flu for  " + dayofWeek[i]+":") ; 
         NumPatientsFlu=sc.nextInt();
         System.out.print("\nTotal Flu After Hours  ") ;
         NumAfterHoursFlu=sc.nextInt();
         
         System.out.print("\nPlease enter Number of Patients Basic for  " + dayofWeek[i]+":") ; 
         NumPatientsBasic=sc.nextInt();
         System.out.print("\nTotal Basic After Hours  ") ;
         NumAfterHoursBasic=sc.nextInt();
         
         
         TotFlu=NumPatientsFlu+NumAfterHoursFlu;
         TotBas=NumPatientsBasic+NumAfterHoursBasic;
         AHoursFlu=(FeeFlu*2)*NumAfterHoursFlu;
         TotalFeeFlu=(NumPatientsFlu*FeeFlu)+AHoursFlu;
         AHoursBasic=(FeeBasic*2)*NumAfterHoursBasic;
         TotalFeeBasic=(NumPatientsBasic*FeeBasic)+AHoursBasic;
         TotalDaily=TotalFeeFlu+TotalFeeBasic;
         Sum = Sum + TotalDaily;
         After = After + (NumAfterHoursBasic+NumAfterHoursFlu);
         normal= normal+(NumPatientsBasic+NumPatientsFlu);
         
         
         System.out.println("\nDay      "+ dayofWeek[i]);
         System.out.println("     Treatment         Total Consultations  After Hours    Total Fee ($)");
         System.out.println("     Flu Injection     "+TotFlu+("                    ")+NumAfterHoursFlu+("              ")+TotalFeeFlu);
         System.out.println("     Basic             "+TotBas+("                    ")      +NumAfterHoursBasic+("              ")+  TotalFeeBasic);
         System.out.println("\n\n ");
         System.out.println("                                                    Total Daily Revenue $"+TotalDaily ); 
         }
         
       
      System.out.println("\n\n ");
         System.out.println("                                                    Total Weekly Revenue $"+Sum ); 
         System.out.println("Total After Hours consultations:    "+After );
         System.out.println("Total Normal Hours consultations:   "+normal );
      
         }  //  end of main
    }  // end of  class
     
    Last edited by a moderator: Jun 5, 2011

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice