iwlu 2 Newbie Poster

Here is my program with Pseudo code which is yukville, :lol:
but not sure i'm on the right track or have straid, any help would be appreiciated.

Exhibit A-1: UML Class Diagram of Class Garage
Garage

+openForBusiness()
-calculateCharges(hoursParked : double): double


Exhibit A-2: Pseudo code for openForBusiness Method of Class Garage
A-2-01) INSTANTIATE a local variable named input of the Scanner class
A-2-02) Define a local int variable named customerNumber and initialize it to 1
A-2-03) Define a local double variable named totalParkingReceipts and initialize it to 0.0
A-2-04) Define a local double variable named parkingCharges
A-2-05) Define a local double variable named hoursParked
A-2-06) Define a local String variable named hoursParkedPrompt and initialize it to
“Enter number of hours parked for customer %2d, or <ctrl>z to stop:Δ[1]
A-2-07) Define a local String variable named programOutput and initialize it to “\nSummary of Today’s Receipts:\n”
A-2-08) CONCATENATE line one of output column headings onto programOutput using method format[2] of the String class:
programOutput += String.format(“\n\t%8sΔΔΔ%6s ΔΔΔ%7s”,”Customer”,”HoursΔ”,”Parking”);
A-2-09) CONCATENATE line two of output column headings onto programOutput using method format of the String class:
programOutput += String.format(“\n\t%8sΔΔΔ%6s ΔΔΔ%7s”,”ΔNumberΔ”,”Parked”,”ΔΔFeeΔΔ”);
A-2-10) DISPLAY the task / programmer identification line followed by a blank line
A-2-11) DISPLAY the “Parking Attendant Activity” heading followed by a blank line
A-2-12) Using method printf, DISPLAY the following prompt
(“\tΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔ” + hoursParkedPrompt, customerNumber)
A-2-13) WHILE (input.hasNext())
A-2-13-1) ASSIGN input.nextDouble() TO hoursParked
A-2-13-2) ASSIGN calculateCharges (hoursParked)[3] TO parkingCharge
A-2-13-3) ADD parkingCharge TO totalParkingReceipts
A-2-13-4) CONCATENATE the following formatted string onto programOutput:
(“\n\t%8dΔΔΔ%6.1fΔΔΔ$%6.2f”, customerNumber, hoursParked, parkingCharge)
A-2-13-5) Using method printf, DISPLAY the following prompt:
(“\tCharge for customer %2d is $%6.2f;Δ” + hoursParkedPrompt,
customerNumber, parkingCharge, ++customerNumber)
A-2-14) END WHILE
A-2-15) CONCATENATE the following formatted string onto programOutput:
(\n\t%-17sΔΔΔ$%6.2f”, “ΔΔΔTotal Receipts”, totalParkingReceipts)
A-2-16) Using method println, DISPLAY programOutput
A-2-17) Using method println, DISPLAY a blank line followed by the “End of program” line


Exhibit A-3: Pseudo code for calculateCharge Method of Class Garage
A-3-01) Define a named constant[4] for minimumParkingCharge with a value of 2.0;
A-3-02) Define a named constant for maximumParkingCharge with a value of 10.0;
A-3-03) Define a named constant for maximumParkingHoursForMinimumParkingCharge with a value of 3.0;
A-3-04) Define a named constant for chargePerHourAfterMinumum with a value of 0.5.
A-3-05) ASSIGN minimumParkingCharge TO parkingCharge
A-3-06) IF hoursParked > maximumParkingHoursForMinimumParkingCharge THEN
ASSIGN minimumParkingCharge plus product of chargePerHourAfterMinumum and
Math.ceil(hoursParked minus maximumParkingHoursForMinimumParkingCharge)
TO parkingCharge
END-IF
A-3-07) IF parkingCharge IS GREATHER THAN maximumParkingCharge THEN
ASSIGN maximumParkingCharge TO parkingCharge
END IF
A-3-06) RETURN parkingCharge

Exhibit B-1: UML Class Diagram of Class GarageTest
GarageTest

+main(args[ ] : String)


Exhibit B-2: Pseudo code for main Method of Class GarageTest
This method has no return value and has one parameter: arg[ ] as type String.
B-2-01) INSTANTIATE object application of class Garage
B-2-02) CALL application’s openForBusiness method


[1] The Greek letter delta Δ in a string is used represent a single space in the string. As a result, replace all Δ characters shown in a string with a single space character.

[2] Use the format method of the String class to format this string. This is similar to using the printf method with format specifiers to format output. The syntax is: String.format(“My %s has %d numbers: %d, %.2f, %d”, “string”, 3, 1, 2.0, 3);

[3] This is a method call.

[4] Named constants are defined as variables with the “final” keyword as a prefix. The value associated with a named constant cannot be changed at run time. In other words, a named constant cannot appear on the left-hand side of the assignment operator in an assignment statement. An example of a named constant is: final double pi = 3.14;

import java.util.Scanner; // program uses class Scanner
public class Garage
{
 private static String hoursParkedPrompt;
 private static Object programOutput;
 // application starting point
 public static void main( String args[] )
 {
  // Instantiate a loacl variable named input of Scanner class
  Scanner input = new Scanner( System.in );
  int customerNumber = 1;
  double totalParkingReceipts = 0.0;
  double ParkingCharges;
  double hoursParked;
  hoursParkedPrompt = "Enter number of hours parked for customer %2d, or <ctrl>z to stop: ";
  String programOutput = "\nSummary of Today's Receipts:\n";
  String line1 = programOutput += String.format ("\n\t%8s   %6s   %7s","Customer","Hours ","Parking");
  String line2 = programOutput += String.format ("\n\t%8s   %6s   %7s"," Numbers ","Parked","  Fee  ");
  System.out.println("\nTask 09-02, Ch06, Programmed by Michael Statham\n");
  System.out.println("\nParking Attendant Activity:\n");
  System.out.printf("\t                                   "+hoursParkedPrompt, customerNumber);
  
        while (input.hasNext());
  hoursParked = input.nextDouble();
  Object parkingCharge = calculateCharges(hoursParked);
  
  
  String.format = programOutput:("\n\t%8d   %6.1f   $%6.2f",customerNumber,hoursParked,parkingCharge);
  System.out.printf("\tCharge for customer %2d is $%6.2f; " + hoursParkedPrompt,
         customerNumber, parkingCharge, ++customerNumber);
  }// end while
     String.format = programOutput:("\n\t%-17s   $%6.2f","   Total Receipts", totalParkingReceipts);
  System.out.println("programOutput");
  System.out.println("\nEnd of program");
      private static Object calculateCharges(double hoursParked) {
  // TODO Auto-generated method stub
  return null;
  final double minimumParkingCharge = 2.0;
  final double maximumParkingCharge = 10.0;
  final double maximumParkingHoursForMinimumParkingCharge = 3.0;
  final double chargePerHourAfterMinimum = 0.5;
  
  double parkingCharge = minimumParkingCharge;
  
  if (hoursParked > maximumParkingHoursForMinimumParkingCharge); 
    parkingCharge = minimumParkingCharge + chargePerHourAfterMinimum +
    Math.ceil(hoursParked - maximumParkingHoursForMinimumParkingCharge);
    
     // end if
     if (parkingCharge > maximumParkingCharge);
      parkingCharge = maximumParkingCharge;
      
        //end if
     return parkingCharge;
     
 }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.