Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   HELP SOS static void methods. and methods that pass parameters (http://www.go4expert.com/forums/help-sos-static-void-methods-methods-t25977/)

lew09302500 5Jun2011 12:33

HELP SOS static void methods. and methods that pass parameters
 
: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



All times are GMT +5.5. The time now is 09:21.