Create three classes the Calculation class, Conversion class and Menu Class.
The Conversion class should have the following methods.
double KMToMiles(double distance)
double MilesToKM(double distance)
double FeetToMetres(double distance)
double MetresToFeet(double distance)
double KgToPounds(double weight)
double PoundsToKg(double weight)
double CelciusToFahrenheit(double temperature)
double FahrenheightToCelcius(double temperature)

The Calculation class should have the following methods.
int SumOfSeries(int start, int end, int incr)
int SumOfArray(int data[], int size)
int ProductOfSeries(int start, int end, int incr)
int ProductOfArray(int data[], int size)
e.g. SumOfSeries(10,20,2) should produce the answer 90
Hint : 10+12+14+16+18+20
Similary ProductOfSeries(100,200,50) should produce 3,000,000
Hint : 100x150x200 = 3,000,000
The Menu class should have the following methods.
void displayMainMenu()
void displayConversionSubMenu()
void displayCalculationSubMenu()
void displayConversionLengthSubmenu()
void displayConversionWeightSubmenu()
void displayConversionTemperatureSubmenu()

The menu class methods should display the options available under each selected menu.
e.g. The displayConversionSubMenu() method should display the following.
Conversion Sub Menu

  1. Sum of Series
  2. Sum of Array
  3. Product of Series
  4. Product of Array
  5. Exit
    If the user selects the sum of array option (option 2), your program should input the size of the array, get
    values to the array from the keyboard, create a Calculation type object and invoke the SumOfArray()
    method to calculate the sum of the Array element and to display it. After displaying the answer the same
    sub menu should be displayed. When the user selects Exit (option 0), you should exit from that sub menu.

Dani AI

Generated

The task breaks cleanly into three responsibilities: pure conversion logic, arithmetic/array calculations, and a menu-driven UI. Keep Conversion and Calculation classes free of I/O and put only printing/input in Menu. As specified the required features, and as asked, start small: implement one method per class, test it, then add the rest. Note the assignment has spelling typos ("Celcius", "Fahrenheight") — either use the exact names your teacher expects or correct them to Celsius/Fahrenheit consistently in your code.

Use well-known constants and one-line conversions in the Conversion class. Keep the return type double for all conversions. Example implementations:

public double kmToMiles(double km) {
    return km * 0.621371;
}

public double celsiusToFahrenheit(double c) {
    return c * 9.0 / 5.0 + 32.0;
}

For Calculation methods, validate inputs (for example, incr != 0) and handle both positive and negative increments. A robust SumOfSeries loops using the sign of incr rather than trying to compute the term count (safer when the step doesn't divide the range evenly):

public int sumOfSeries(int start, int end, int incr) {
    if (incr == 0) throw new IllegalArgumentException("incr must not be 0");
    int sum = 0;
    if (incr > 0) {
        for (int i = start; i <= end; i += incr) sum += i;
    } else {
        for (int i = start; i >= end; i += incr) sum += i;
    }
    return sum;
}

Be careful with products and large sums: int can overflow; prefer long or BigInteger for product routines. For the Menu class, have each display... method only print options. Drive input with a loop that reads an option, validates it, calls the logic method, shows results, then re-displays the submenu until the user picks Exit. Common runtime issues: forgetting to consume newline after nextInt(), closing Scanner early, and not validating array size input. Test the given examples (e.g., the sample series/product cases) and add a few edge tests (zero step, start > end, single-term ranges) to confirm correct behavior.

Ok. You have started, so that’s good. How far did you get and what’s stopping you from progressing further?

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.