1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

HELP SOS static void methods. and methods that pass parameters

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

  1. lew09302500

    lew09302500 New Member

    :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)

    // 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]+":") ; 
         System.out.print("\nTotal Flu After Hours  ") ;
         System.out.print("\nPlease enter Number of Patients Basic for  " + dayofWeek[i]+":") ; 
         System.out.print("\nTotal Basic After Hours  ") ;
         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