Does anyone know where I can find some info on where to start on this program?

Assume the tanker is a cylinder of length 19.35 feet and volume 1320 gallons. What is the

diameter in feet of the tanker truck?

To solve this problem, write a Java program to calculate the diameter. For full credit, your

Java application must follow these specifications.

1. The program must interactively input the capacity of the tanker in gallons and its

length in feet. This should be done in the main method of your Tester class.

2. The input data should then be used to construct a TankerTruck object. You will

need to write the TankerTruck class.

3. A TankerTruck method should be used by main to calculate the resulting diameter of

the truck in feet.

4. Your program should use the standard Java constant for the math constant PI.

5. The output should be displayed using fixed-point notation, rounding to one decimal

place of precision

if anyone could help I would greatly appreciate it.

Re: Does anyone know where I can find some info on where to start on this program?

First get the needed equations for solving the problem. Then work on a design for the GUI to get the needed numbers from the user. Then write the code to use use the user's input to solve the equations.

Re: Does anyone know where I can find some info on where to start on this program?

I am basically converting a c++ file to java: I am new to java. I am just trying to convert it.

C++ Code

Quote:

#include <iostream>

#include <cmath>

#include <cstdlib>

#include <iomanip>

using namespace std;

int main()

{

double volume = 0;

double length = 0;

double radius = 0;

cout << " What is the max volume of water in tanker? : ";

cin >> volume;

cout << " What is the length of the tanker in feet? : ";

cin >> length;

radius = sqrt(volume/length/M_PI);

cout << setprecision(1) << fixed;

cout << " The diameter in feet is: " << radius*2 << endl;

system("pause");

return 0;

}

Re: Does anyone know where I can find some info on where to start on this program?

Ok, what parts are you having problems with?

Re: Does anyone know where I can find some info on where to start on this program?

Well I have got this far in the translation: but the user inputs are wrong, and I want to break the program up into a class and a tester.

ex.:

Code Java:

public class TankerTruck
{
public static int Main()
{
double volume = 0;
double length = 0;
double radius = 0;
System.out.print(" What is the max volume of water in tanker? : ");
cin >> volume;
System.out.print(" What is the length of the tanker in feet? : ");
cin >> length;
radius = Math.sqrt(volume / length / Math.PI);
System.out.printf("%.1f", " The diameter in feet is: ");
System.out.printf("%.1f", radius * 2);
System.out.printf("%.1f", "\n");
system("pause");
return 0;
}
}

Re: Does anyone know where I can find some info on where to start on this program?

Quote:

the user inputs are wrong

See the Scanner class for methods to read input from a user.

Re: Does anyone know where I can find some info on where to start on this program?

I am here, where to next?

ex.:

Code Java:

import java.util.*;
public class TankerTruck
{
public static int Main()
{
Scanner userInputScanner = new Scanner(System.in);
System.out.print(" What is the max volume of water in tanker? : ");
double volume = userInputScanner.nextDouble();
System.out.print(" What is the length of the tanker in feet? : ");
double length = userInputScanner.nextDouble();
radius = Math.sqrt(volume / Length / Math.PI);
System.out.printf("%.1f", " The diameter in feet is: ");
System.out.printf("%.1f", radius * 2);
System.out.printf("%.1f", "\n");
system("pause");
return 0;
}
}

Re: Does anyone know where I can find some info on where to start on this program?

Quote:

I am here, where to next?

What does the code do now?

Does it compile and execute without any errors?

What does the code need added?

Re: Does anyone know where I can find some info on where to start on this program?

No "radius" is all wrong.

Re: Does anyone know where I can find some info on where to start on this program?

Quote:

"radius" is all wrong.

Can you explain?

Is it a problem coding an equation

or is the equation wrong?

Post the contents of the command prompt window showing the input and output and add some comments saying what the output should be.

Re: Does anyone know where I can find some info on where to start on this program?

ex.:

Code Java:

import java.util.*;
import static java.lang.Math.PI;
import java.lang.*;
public class TankerTruck
{
public static int Main()
{
Scanner userInputScanner = new Scanner(System.in);
System.out.print(" What is the max volume of water in tanker? : ");
double volume = userInputScanner.nextDouble();
System.out.print(" What is the length of the tanker in feet? : ");
double length = userInputScanner.nextDouble();
double radius = PI / volume / length;
System.out.printf("%.1f", radius * 2);
System.out.printf("%.1f", " The diameter in feet is: ");
System.out.printf("%.1f", "\n");
}
}

Re: Does anyone know where I can find some info on where to start on this program?

Re: Does anyone know where I can find some info on where to start on this program?

No because I don't know what I am doing. I write c++ not java.

Re: Does anyone know where I can find some info on where to start on this program?

If you want to write a java program you will need to learn some java.

If you need help with the code, ask some specific questions about the problems you are having.

If there are error messages, copy the full text of the messages and paste it here.

Re: Does anyone know where I can find some info on where to start on this program?

ex.:

Code Java:

import java.util.*;
import static java.lang.Math.PI;
import java.lang.*;
public class TankerTruck
{
public static int Main()
{
Scanner userInputScanner = new Scanner(System.in);
System.out.print(" What is the max volume of water in tanker? : ");
double volume = userInputScanner.nextDouble();
System.out.print(" What is the length of the tanker in feet? : ");
double length = userInputScanner.nextDouble();
double radius = PI / volume / length;
double diameter = radius * 2;
System.out.printf("%.1f", " The diameter in feet is : %d%n", diameter);
}

Its asking for a return statement??? It will not compile.

Re: Does anyone know where I can find some info on where to start on this program?

Quote:

Its asking for a return statement?

This method definition says the method will return an int value: The compiler requires that the method have a return statement that returns an int.

Either change the definition of the method to return void

or return an int value.