Results 1 to 12 of 12
  1. #1
    clemsontigers is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default help w/ conversion of degrees(CtoF, FtoC)

    here is what we're supposed to do
    This assignment is a Celsius to Fahrenheit and Fahrenheit to Celsius temperature conversion program.

    Write a class that contains the following two methods ( class will have a total of 3 methods ):
    public static double celtofahr ( double celsius)
    and public static double fahrtocel ( double fahrenheit )

    main should prompt the user for a celsius, call / use the celtofahr method to do the conversion, next display the result to the user. Next, prompt the user for a Fahrenheit, call / use the fahrtocel method to do the conversion, next display the result to the user.

    Note : the formula for conversion is
    fahrenheit = ( ( 9.0 / 5.0 ) * celsius ) + 32

    WHERE DO I PUT THE STRING TO PROMPT THE USER TO ENTER EACH DEGREE?

    here is my code

    public class Assign8_Roberts{

    private double fahrenheit;
    private double celsius;
    private String displayString;

    public Assign8_Roberts (double Fahrenheit, double Celsius)
    {
    this.fahrenheit = Fahrenheit;
    this.celsius = Celsius;
    }

    public double GetFahrenheitTemp()
    {
    return this.fahrenheit;
    }

    public double FahrtoCel(double fahrenheit)
    {
    double result = (fahrenheit - 32)/1.8;
    return result;
    }

    public double GetCelsiusTemp()
    {
    return this.celsius;
    }

    public void FahrenheitTemp(double fahrenheitVal)
    {
    this.fahrenheit = fahrenheitVal;
    }

    public double CeltoFahr(double celsius)
    {
    double result = (1.8 * celsius) + 32;
    return result;
    }

    public void CelsiusTemp(double celsiusVal)
    {
    this.celsius = celsiusVal;
    }

    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by clemsontigers View Post
    here is what we're supposed to do...

    main should prompt the user for a celsius, call / use the celtofahr method to do the conversion, next display the result to the user. Next, prompt the user for a Fahrenheit, call / use the fahrtocel method to do the conversion, next display the result to the user.

    ....


    WHERE DO I PUT THE STRING TO PROMPT THE USER TO ENTER EACH DEGREE?
    The instructions tell you where -- see the red above. You're missing a method.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

  4. #4
    clemsontigers is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default

    To DB(aka java forum police):does it really matter if i posted it on another board..isnt that what these are for?? imma post this same reply on the other board to p!$$ u off

    to the other guys who help:thanks

    here's my updated program..when i run it, it runs previous assignment that i've done instead of this one so something isnt right

    import java.util.Scanner ;

    public class Assign8_Roberts{


    private double fahrenheit;
    private double celsius;
    private String displayString;

    public Assign8_Roberts (double Fahrenheit, double Celsius)
    {
    this.fahrenheit = Fahrenheit;
    this.celsius = Celsius;
    }

    public double GetFahrenheitTemp()
    {
    return this.fahrenheit;
    }

    public double FahrtoCel(double fahrenheit)
    {
    double result = (fahrenheit - 32)/1.8;
    return result;
    }

    public double GetCelsiusTemp()
    {
    return this.celsius;
    }

    public void CelsiusTemp(double celsiusVal)
    {
    this.celsius = celsiusVal;
    {
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter a value: ");

    float c = scan.nextFloat();

    //use c as input to your methods
    }
    }
    public void FahrenheitTemp(double fahrenheitVal)
    {
    this.fahrenheit = fahrenheitVal;

    {
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter a value: ");

    float f = scan.nextFloat();

    //use f as input to your methods
    }

    }

    public double CeltoFahr(double celsius)
    {
    double result = (1.8 * celsius) + 32;
    return result;
    }



    }

  5. #5
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by clemsontigers View Post
    To DB(aka java forum police):does it really matter if i posted it on another board..isnt that what these are for?? imma post this same reply on the other board to p!$$ u off
    No one wants to waste time working out someone's problem when it's already been solved elsewhere in a cross-post. Ignoring this implies that the poster doesn't respect the time commitment made by the volunteers of the various forums. The best thing to do is to notify all if you've made cross-posts and where you've made them. This forum is no different from any of the others in this regard.

    Saying "pi$$-off" may feel good at the time, but isn't likely to encourage others to help you further.

    Suerte.

  6. #6
    clemsontigers is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default

    ok i've changed my program around and while im getting the correct results, im not sure if i have it designed the way the assignment says

    public class Assign8_Roberts{

    public static void main(String[] args)
    {

    double fahrenheit;
    double celsius;

    Scanner input = new Scanner(System.in);

    System.out.println("Enter the Degrees in Fahrenheit");
    fahrenheit = input.nextDouble();
    celsius = (5.0/9.0)*(fahrenheit - 32);
    System.out.println("The number of degrees of Fahrenheit: " + fahrenheit);
    System.out.println("Converted to Celsius is: " + celsius);//end convert to celsius

    System.out.println("Enter the Degrees in Celsius");
    celsius = input.nextDouble();
    fahrenheit = (9.0/5.0)* celsius + 32;
    System.out.println("The number of degrees of Celsius: " + celsius);
    System.out.println("Converted to Fahrenheit is: " + fahrenheit);
    }

    }

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Agree that the cross-posting issue is important. OP, you might want to address this, let us know if there are any more cross-posts and let us know that you will notify us and all other forums for cross-posts in the future. Thank you for your cooperation.

  8. #8
    clemsontigers is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default

    im getting errors in the output now

    import java.util.Scanner;

    public class Assign8_Roberts{

    //Converts between CandF
    private double celsius;
    private double fahrenheit;

    //converts from CtoF
    public void CeltoFahr(double temp){
    fahrenheit = (9.0/5.0*temp) + 32;
    celsius = temp;
    }

    //converts from FtoC
    public void FahrtoCel(double temp){
    celsius = (5.0/9.0) * (temp-32);
    fahrenheit = temp;
    }

    //displays temp in C
    public void outputCelsius(){
    System.out.println("The temperature is " + celsius + "C");
    }

    //displays temp in F
    public void outputFahrenheit(){
    System.out.println("The temperature is " + fahrenheit + "F");
    }

    //output
    public static void main(String[] args) {
    Scanner temp = new Scanner(system.in);
    temp t = new temp();
    t.setCelsius(100);
    t.outputFahrenheit();
    t.outputCelsius();
    }

    }

  9. #9
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Snapping at a respected member of this forum because he informed you of a forum etiquette faux pas is not a good way to get help. Why crossposting is looked down upon has been explained already.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  10. #10
    clemsontigers is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default

    Im new to the board and didn't know about the crossposting policy and thats why I apologized

  11. #11
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    To DB(aka java forum police):does it really matter if i posted it on another board[?]

    A couple of things. First, it matters to me. I know you didn't address the question at me, but I'll answer anyway because that's how forums and dialogue in general works: you say/ask/observe something and people say/ask/observe things in response. And it matters to me mostly because crossposting frustrates that process of dialogue. Anyone participating in a discussion either doesn't know about - or has to jump through hoops to see - the rest of the dialogue. When you create a thread you offer it to the community. Those who respond, by responding make it their own. The thread is common property.

    Secondly, "police"? That is simply not how it works. It's rhetoric, not fact. There are no police. What there are people engaged in dialogue (see above) who, by their participation, establish and sustain norms of conduct. No police: just people being civil.
    Last edited by pbrockway2; 11-08-2010 at 10:02 PM.

  12. #12
    clemsontigers is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

Similar Threads

  1. XLS to PDF conversion
    By nitin2k2k in forum Advanced Java
    Replies: 18
    Last Post: 07-02-2013, 11:17 AM
  2. [j2me] sprite rotation with degrees
    By Rooneyz in forum CLDC and MIDP
    Replies: 0
    Last Post: 07-06-2009, 03:40 PM
  3. Doc to Pdf conversion
    By praveen.kb in forum Advanced Java
    Replies: 2
    Last Post: 01-16-2009, 12:27 PM
  4. string conversion??
    By j2vdk in forum New To Java
    Replies: 13
    Last Post: 09-19-2008, 03:35 PM
  5. Conversion from wav to vox
    By bozovilla in forum Advanced Java
    Replies: 1
    Last Post: 07-31-2008, 05:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •