Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6806013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:39:29+00:00 2026-05-26T19:39:29+00:00

Again, I am a java n00b and I am trying to learn from scratch

  • 0

Again, I am a java n00b and I am trying to learn from scratch and running into some embarrassing problems.

I got an Account class as follows:Account.java

 public class Account 
 {
    protected double balance;

    // Constructor to initialize balance
    public Account( double amount )
{
    balance = amount;
}

    // Overloaded constructor for empty balance
    public Account()
{
    balance = 0.0;
}

    public void deposit( double amount )
{
    balance += amount;
}

    public double withdraw( double amount )
{
            // See if amount can be withdrawn
    if (balance >= amount)
    {
        balance -= amount;
                    return amount;
    }
    else
            // Withdrawal not allowed
                    return 0.0;
}

    public double getbalance()
{
            return balance;
}
  } 

I am trying to use extends to inherit the methods and variables in this class. So, I used InterestBearingAccount.java

 import Account;

 class InterestBearingAccount extends Account
  {
    // Default interest rate of 7.95 percent (const)
    private static double default_interest = 7.95;

    // Current interest rate
    private double interest_rate;

    // Overloaded constructor accepting balance and an interest rate
    public InterestBearingAccount( double amount, double interest)
{
    balance = amount;
    interest_rate = interest;
}

    // Overloaded constructor accepting balance with a default interest rate
    public InterestBearingAccount( double amount )
{
    balance = amount;
    interest_rate = default_interest;
}

    // Overloaded constructor with empty balance and a default interest rate
    public InterestBearingAccount()
{
    balance = 0.0;
    interest_rate = default_interest;
}

    public void add_monthly_interest()
{
            // Add interest to our account
    balance = balance +
                    (balance * interest_rate / 100) / 12;
}

 }

I get an error saying import error ‘.’ expected when I try to compile. All the files are in the same folder.

I did javac -cp . InterestBearingAccount

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:39:30+00:00Added an answer on May 26, 2026 at 7:39 pm

    If all the files are in the same folder / package, you don’t need to do an import.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get into java again (it's been a few years). I never
I have problems again with my Mac running Java 1.5.... where do I get
I have deleted Java class and compiled again after making changes to some image
I need your expertise once again. I have a java class that searches a
I'm about to jump into Java development again after a number of years. The
I am learning Java (slowly) from the ground up, but every now and again
I got a java web project handling several objects (again containing n objects of
I'm trying to run a sample Java application from the command promopt but I'm
I'm just starting Java ... again. I just made a simple program class first
I'm spending some time with Java again after a long break on the .NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.