Results 1 to 2 of 2
  1. #1
    Bit_Void is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Default Farenheit to Celcius and Vice-Versa Program Help?

    Hi, I'm having trouble with this program. It's supposed to be able to convert a temperature in farenheit to celcius and vice-versa in the format "## Scale". Example: "100 F". If a letter other than F or C is chosen, the program should be able to retain the number input and ask the user again to enter a valid letter for a scale. The number, the space, and the letter are all to be properly considered.

    I can't compile it because I have an incompatible types error for typeStr as shown here. What should I do to fix the problem?

    Java Code:
    import java.util.Scanner;
    public class Conversion
    {
        public static void main(String[] args)
        {
            System.out.println("This program converts degrees");
            boolean inputValid = true;
            int temperature;
            
            
            Scanner keyboard = new Scanner(System.in);
            boolean good = false;
            char typeStr = ' ';
            
           
             do
            {
            System.out.println("Enter the temperature (example: 100 F)");
            temperature = keyboard.nextInt();
            keyboard.next( );
            good = false;
            }
            
            while (!good);
            {
                typeStr = keyboard.next();
                keyboard.nextLine();
                type = TypeStr.charAt(0);
                If (type == 'c' || type == 'C');
                    { 
                    type = 'C';
                    good = true;
                    }
                If (type == 'f' || type == 'F');
                    {
                    type = 'F';
                    good = true;
                    }
                If (!good);
                    {
                    System.out.println("The letter input not good.");
                    System.out.println("Please give a valid temperature measure.");
                    }
               
                //End Text
                System.out.println("Press Q to Quit");
                System.out.println("or anything else to make a new calculation");
                answer = keyboard.next();
             
            } 
        }
    }

  2. #2
    Bit_Void is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Default Re: Farenheit to Celcius and Vice-Versa Program Help?

    Never mind, figured it all out.

Similar Threads

  1. Recursion to Iteration, and Vice Versa
    By penguinCoder in forum New To Java
    Replies: 0
    Last Post: 02-13-2013, 11:57 PM
  2. Replies: 5
    Last Post: 04-16-2009, 07:30 PM
  3. Postfix into prefix and vice versa
    By sfe23 in forum New To Java
    Replies: 9
    Last Post: 02-19-2009, 11:37 PM
  4. Converting to ASCII and vice-versa
    By pheonix in forum New To Java
    Replies: 2
    Last Post: 09-09-2008, 05:43 AM
  5. Document conversion PDF to MS doc and vice versa
    By abintoms in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 01:45 AM

Tags for this Thread

Posting Permissions

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