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

  • Home
  • SEARCH
  • 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 8929485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:40:51+00:00 2026-06-15T08:40:51+00:00

Hey everybody here is my code: package Chapter5; import java.util.Scanner; public class MainMenu extends

  • 0

Hey everybody here is my code:

package Chapter5;

import java.util.Scanner;


public class MainMenu extends Integration
{

static Scanner s = new Scanner(System.in);
static int c;
static double lower, upper;
static double Curves;
static double sum = 0;


public static void main(String[] args) 
{

    while(true)
    {
        System.out.println("Please choose one of the options");
        System.out.println("1: Calculate the area between two curves");
        System.out.println("2: Calculate the volume when two curves are revolved about a disk");
        System.out.println("3: Calculate the volume when a single curve is revolved about a shell");
        System.out.println("4: Quit");
        c = s.nextInt();
        if(c == 1)
        {
            System.out.println("Area between two curves");
            System.out.println("Please enter the lower limit");
            lower = s.nextInt();
            System.out.println("Please enter the upper limit");
            upper = s.nextInt();
            System.out.print("Lower limit: " + lower);
            System.out.println("  Upper limit: " + upper);
            System.out.println("The area under the f curve: " + sumf);
            System.out.println("The area under the g curve: " + sumg);
            sum = sumf - sumg;
            System.out.println("Area between the two curves = " + sum);
        }
        if(c == 2)
        {
            System.out.println("Working");
        }
        if(c == 3)
        {
            System.out.println("Working");
        }
        if(c == 4)
        {
            break;

        }
    }
}

Here is my Integration class:

   package Chapter5;

   /*Author: Cory Zander
   * Purpose: Find the area and volume between two curves
   */
   public class Integration 
   {

static double x;
static double dx;
static double f, g;
static double sumg = 0;
static double sumf = 0;
public static double f(double x) 
{
    f = x * Math.exp(x);
    return x;


}
public static double g(double x) 
{
    g = Math.pow(x, 2);
    return x;

}

public static double Areaf(double lower, double upper)
{
    int i;
    x = lower;
    dx = (upper - lower)/2000;
    for(i = 0; i <= 2000; i++)
    {
        if(i == 0 || i == 2000)
        {
            sumf += f;
        }
        else
        {
            sumf += 2 * f;
        }
        x += dx;


    }
    sumf *= dx/2;
    return sumf;


}
public static double Areag(double lower, double upper)
{
    int i;
    x = lower;
    dx = (upper - lower)/2000;
    for(i = 0; i <= 2000; i++)
    {
        if(i == 0 || i == 2000)
        {
            sumg += g;
        }
        else
        {
            sumg += 2 * g;
        }
        x += dx;


    }
    sumg *= dx/2;
    return sumg;
}

Okay I just edited this and fixed the areaf and areag issue, but for some reason when I get the area under the f curve I still get 0. Why is it not taking the sumf from the Integration class

  • 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-06-15T08:40:52+00:00Added an answer on June 15, 2026 at 8:40 am
    public static void main(String[] args){
        if (c == 1){
            //...
            double area1 = Integration.Areaf(lower, upper);
            double area2 = Integration.Areag(lower, upper);
            sum = area1 - area2;//sum and minus used?
            System.out.println("Area between the two curves = " + sum);
       }
    }
    

    Also you used inheritance incorrectly cause all your methods in base class (Integration) are static. You can simply delete extends clause from sub class or adjust it in correct way.

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

Sidebar

Related Questions

Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>
hey everybody i am trying to implement code for finding order statistic but i
Hey everybody, i am deploying my code from a cluster running on ubuntu onto
Hey everybody, this is what I have going on. I have two text files.
Hey everybody, I'm very confused about how to use two different Cell Types in
hey everybody... I'm running xampp test server on my system. I was wondering if
Hey everybody. So, I'm creating this kind of a social network script for a
Hey everybody, got an interesting question I think. I've got a Silverlight3 application which
Hey all, I'm working on cleaning up my code from previous semesters. Previously I
Hey guys I'm following the rails tutorial found here http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ and I've gotten to

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.