-2

I'm working on a project for my class and every time I try to compile I get the following error in jGrasp:

Lab 1.java:26: error: class, interface, or enum expected
Module main()
^
1 error

I have tried looking for the error in my code but can't find it if anyone sees what is wrong that I'm overlooking that would very helpful and I would appreciate any corrections that would get rid of that error. The code is below so you can get a thorough look at it.

/*Problem: Rent Analyze, design and code the following application:
It allows a user to enter the rent of a home and calculate the first month payment. The first month payment includes a security deposit (equal to the 2 months rent) and the first month's rent.Display the following: each month’s rent, amount of security deposit and the final payment.

Input
User: 1. Rent amount 
Given: N/A

Processing: 1. Calculate security deposit = 1 month rent * 2
        2. Calculate total first month rent = 
            1 month rent + security deposit

Output: 1. Price for 1 month of rent
    2. Price of security deposit 
    3. Total for first months' rent 
*/

//Design

Module main()

//Declarations
Declare Real oneMonthRent = 0.0//One month rent entered by user
Declare Real securityDeposit = 0.0//2 months worth of rent
Declare Real firstMonthRent = 0.0//Security deposit + 1 month rent

//Input
Set oneMonthRent = Call getRent()//user entered

//Processing
Set securityDeposit = Call calcDeposit(oneMonthRent)//oneMonthRent +    oneMonthRent
Set firstMonthRent = Call calcFirstMonthRent(oneMonthRent, securityDeposit)//oneMonthRent + securityDeposit

//Output
Call showRentAnalysis(oneMonthRent, securityDeposit, firstMonthRent)//Displays oneMonthRent, Deposit, and total first month

End Module

//Gets monthly rent cost from user
Function Real getRent()
Declare Real nRent = 0.0//local variable

Display "Enter monthly rent "

Input nRent

Return nRent
End Function

//Calculates the Security deposit
Function Real calcDeposit(Real noneMonthRent)
Declare Real ndeposit = 0.0//local variable

Set ndeposit = noneMonthRent + noneMonthRent

Return ndeposit
End Function

//Calculates total first month rent
Function Real calcFirstMonthRent(Real noneMonthRent,Real nsecurityDeposit)
Declare Real nfirstMonthRent = 0.0//local variable

Set nfirstMonthRent = noneMonthRent + nsecurityDeposit

Return nfirstMonthRent
End Function

//Displays  1 month of rent, security deposit, and final for first month
Module showRentAnalysis(Real noneMonthRent,Real nsecurityDeposit,Real nfirstMonthRent)

Display "One month worth of rent cost ", noneMonthRent
Display "Security deposit cost ", nsecurityDeposit
Display "Total for first month of rent is ", nfirstMonthRent
End Module

1 Answers1

0
public class Main {

    public static void main(String[] args) {
        double rent = 500.50;
        double securityDeposit = rent*2;
        double firstMonth = rent+securityDeposit;

        System.out.println(firstMonth);

    }

}
user253751
  • 57,427
  • 7
  • 48
  • 90
TuckerB
  • 3
  • 5