-1

I want to make a program for a boat. It will ask the passenger number of passengers how much they each get paid. Then, it will give me the revenue and based on that, I will calculate the monthly revenue.

package com.company;

class Boat {
    private int passenger;  // total number of passengers
    private int cost; // cost per passenger
    private int RevenueCalculator;


    public Boat(int newpassenger, int newcost) {
        this.passenger = newpassenger;
        this.cost = newcost;
    }

    public int computeRevenue() {
        int RevenueCalculator;
        RevenueCalculator = this.cost * this.passenger;
        System.out.println("How many passengers");
        System.out.println("Cost per passenger");
        return RevenueCalculator;

    }
}

I ran this program and this error pop up:

Error: Could not find or load main class com.company.Main Caused by: java.lang.ClassNotFoundException: com.company.Main.

How do I fix it?

Anish B.
  • 9,111
  • 3
  • 21
  • 41
Goblinkiller
  • 99
  • 1
  • 7
  • Well printing after the return is not correct. Otherwise, looks reasonable assuming all passengers paid the same price. – Elliott Frisch Oct 05 '19 at 23:01
  • can you tell me how I can make input such as number of pasenger and how much they paid to get the revenue. i used print beacuse i wanted to see it in the termina,l – Goblinkiller Oct 05 '19 at 23:09
  • Please note that Stack Overflow is meant to address specific technical issues, like "I tried this code and got X but I expected Y. How do I fix it?" If we're being generous here, your question is more along the lines of design assistance. "Am I heading in the right direction" isn't a technical question. Please familiarize yourself with the rubric for [how to ask](https://stackoverflow.com/help/how-to-ask) good questions which will receive good answers. – MarsAtomic Oct 05 '19 at 23:13
  • Possible duplicate of [What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?](https://stackoverflow.com/questions/1457863/what-causes-and-what-are-the-differences-between-noclassdeffounderror-and-classn) – Alessandro Da Rugna Oct 06 '19 at 05:07

1 Answers1

0

See here how to get user input in java:

How can I get the user input in Java?

Also you will need to create another 'test' class and set there a main function where you use the Boat class object.

Josh W.
  • 102
  • 7