Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 16 of 16

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

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default 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.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    Mvxexty1001 (May 6th, 2014)

  4. #3
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default 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

    #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;

    }

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default 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?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #5
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default 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.:
    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;
     
    	}
    }

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

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

    the user inputs are wrong
    See the Scanner class for methods to read input from a user.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #7
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

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

    I am here, where to next?

    ex.:
    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;
     
    	}
    }

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

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

    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?
    If you don't understand my answer, don't ignore it, ask a question.

  10. #9
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

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

    No "radius" is all wrong.

  11. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

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

    "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.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #11
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

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

    ex.:
    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");
    }
    }

  13. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

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

    Does it work now?
    If you don't understand my answer, don't ignore it, ask a question.

  14. #13
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default 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.

  15. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  16. #15
    Junior Member
    Join Date
    May 2014
    Posts
    17
    Thanks
    6
    Thanked 0 Times in 0 Posts

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

    ex.:
    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.

  17. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

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

    Its asking for a return statement?
    This method definition says the method will return an int value:
     public static int Main()
    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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Start.java:22: error: cannot find symbol
    By SPatel in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 25th, 2013, 01:20 PM
  2. How should I start creating this program? Help
    By illegit in forum Java Theory & Questions
    Replies: 8
    Last Post: May 16th, 2013, 10:34 AM
  3. Where does the program start?
    By CrestaMan in forum Java Theory & Questions
    Replies: 12
    Last Post: May 10th, 2012, 12:16 PM
  4. [SOLVED] Program to find how many letters start with vowels
    By Lokesh in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 14th, 2011, 05:58 AM
  5. SIGAR to find CPU info-problem
    By ttsdinesh in forum Exceptions
    Replies: 7
    Last Post: October 4th, 2009, 10:33 AM