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 2 of 2

Thread: Simple yes/no function...

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple yes/no function...

    I'm new to Java, I'm writing a simple application to convert celcius into farenheit just to teach myself some things.

    So far I've written this (to generally get some information from the user):
    import java.util.Scanner;
    import java.lang.Object;
    import java.lang.Boolean;
     
    public class Code 
    {
    	public static void main(String args[])
    	{
    	//Declarations
    	Scanner scan = new Scanner(System.in);
    	String string1, string2, yes, no;
    	double num1;
    	double num2;
     
    	//First prompts
    	System.out.println("Enter name:");
    	string1 = scan.nextLine();
    	System.out.println("Enter surname:");
    	string2 = scan.nextLine();
     
    	//Yes/no function
    	System.out.println("Name: " + string1 + " " + string2 + "," + " is this correct?");
    	System.out.println("Y/N?");
    	}
    }
    In the yes/no function part I want to write a code which does the following: when the user presses 'Y', the code continues, when the user presses 'N' the code goes back to the first line.
    After this I'll write the rest of the code which converts celcius into farenheight, this I can do.
    Last edited by JavaPF; November 11th, 2011 at 09:29 AM. Reason: Use highlight tags!


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Simple yes/no function...

    In future, please use highlight tags around your code (see my signature)

    Is there a question here?

    I suggest you read:

    The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. need help with a function...
    By fallout87 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 2nd, 2011, 06:42 AM
  2. About the ackermann function...
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 25th, 2011, 10:24 AM
  3. Need Help on the Interface Function
    By yel_hiei in forum Object Oriented Programming
    Replies: 12
    Last Post: July 29th, 2010, 08:27 AM
  4. Substring function
    By bristol580 in forum Java SE APIs
    Replies: 2
    Last Post: November 12th, 2009, 11:29 AM
  5. Function of difference between two numbers
    By uplink600 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 13th, 2009, 06:57 AM

Tags for this Thread