Please help me to do this project. Thanks

Discussion in 'Programming General' started by phuthanvinh, Sep 24, 2007.

Please help me to do this project. Thanks
  1. Unread #1 - Sep 24, 2007 at 10:28 PM
  2. phuthanvinh
    Referrals:
    0

    phuthanvinh Guest

    Please help me to do this project. Thanks

    I wrote this project with code, unsure



    public class Project1
    {

    public static void main(String[] args) // Declarations
    {

    Scanner scan = new Scanner( System.in); // Scanner class to read the data from the system.in

    int Tokyo; // read the number of input
    System.out.print("Please enter the temperature for Tokyo in Celsius: ");
    Tokyo = scan.nextInt();
    System.out.println("The temperature of Tokyo in Celsius is: " + Tokyo + "C" );

    int Nepal;
    System.out.print("Please enter the temperature for Nepal in Celsius: ");
    Nepal = scan.nextInt();
    System.out.println("The temperature of Nepal in Celsius is: " + Nepal + "C" );

    int Bethlehem;
    System.out.print("Please enter the temperature for Bethlehem in Fahrenheit: ");
    Bethlehem = scan.nextInt();
    System.out.println("The temperature of Bethlehem in Fahrenheit is: " + Bethlehem + "F" );

    int Sa;
    System.out.print("Please enter the temperature for South Africa in Fahrenheit: ");
    Sa = scan.nextInt();
    System.out.println("The temperature of South Africa in Fahrenheit is: " + Sa + "F" );




    // Convert values
    TokyoD = (Tokyo * (9.0/5.0)) + 32;
    NepalD = (Nepal * (9.0/5.0)) + 32;
    BethlehemD = (Bethlehem-32) * (5.0/9.0);
    SaD = (Sa-32) * (5.0/9.0);

    Double Tokyo2 = ((double)Tokyo * (9.0/5.0)) + 32;
    Double Nepal2 = ( (double)Nepal * (9.0/5.0)) + 32;
    Double Bethlehem2 = ((double)Bethlehem-32) * ( 5.0/9.0);
    Double Sa2 = ((double)Sa-32) * (5.0/9.0);

    // Print information
    System.out.println("Tokyo " + Tokyo + "C\nNepal " + Nepal + "C\nBethlehem " + Bethlehem + "F\nSouth Africa " + Sa + "F");

    System.out.println();

    // Print both fahrenheit and celcius for each location
    System.out.println("Tokyo " + (double)Tokyo + "C " + TokyoD + "F");
    System.out.println ("Rome " + (double)Nepal + "C " + NepalD + "F");
    System.out.println("Athens " + BethlehemD + "C " + (double)Bethlehem + "F");
    System.out.println ("Auckland " + SaD + "C " + (double)Sa + "F");
    }
    } //End of program.
     
  3. Unread #2 - Sep 24, 2007 at 11:33 PM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Please help me to do this project. Thanks

    Seems to work.
     
  5. Unread #3 - Sep 25, 2007 at 8:54 PM
  6. phuthanvinh
    Referrals:
    0

    phuthanvinh Guest

    Please help me to do this project. Thanks

    thanks
     
  7. Unread #4 - Sep 25, 2007 at 9:13 PM
  8. phuthanvinh
    Referrals:
    0

    phuthanvinh Guest

    Please help me to do this project. Thanks

    you are good
     
  9. Unread #5 - Sep 25, 2007 at 9:27 PM
  10. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Please help me to do this project. Thanks

    I started learning to program when I was 11. Started with Visual Basic 2003 .Net, learned a bit of VB6, but now my main programming languages are Visual Basic 2005 .Net, Visual Basic 2008 Beta 2 .Net, a small amount of C++ and some Java.

    Nowadays if I want to learn something, I download an ebook on it, and read through it even if I get bored. I just push myself to read it so I don't say "ah I'll come back later" because thats practically like saying you aren't going to do it.

    So yea, I dedicate hours and hours to programming each day so I can learn more. I guess it'll pay off in the future.

    Java is really easy once you get a grasp of it. If you want to make GUI applications (Graphical user interface) I'd recommend downloading an IDE (Integrated Development Environment) called NetBeans. NetBeans has a GUI Builder, that uses Swing (a set of classes made in java to help make GUIs) that makes it extra easy, so give it a go.

    Remember: Patience is the key. If you want to take programming up as a courrier I recommend you learn outside of school, and study a few of Java's built-in classes each day just as a bit of practice. After about a year you'll be at proffessional level. And proffessional level is when you start something harder (i.e. C++).

    Here are a few terms you might want to get to know:

    Method : Commonly called a function in other languages. Methods execute a block of code. All methods return a value except for voids, which return nothing.
    Return : Returning a value means to pass a value on after a method is finished. i.e. if you made a method that calculated a number, you would most likely return that number from that method rather than storing the number in a seperate variable.
    Arguments : The types and objects passed to a method before execution. Arguments are not to be confused with parameters.
    Parameters : These identify the types and objects to be passed to a method before execution. Any arguments passed to a method must be the same type/object defined in the parameters.
    AWT : Abstract Window Toolkit. This is the base library for creating Java GUI applications.
    Swing : Swing is expanded upon AWT. Swing is generally used more often because it is thought to be better.
     
  11. Unread #6 - Sep 26, 2007 at 12:07 AM
  12. phuthanvinh
    Referrals:
    0

    phuthanvinh Guest

    Please help me to do this project. Thanks

    thanks
     
  13. Unread #7 - Sep 26, 2007 at 12:23 AM
  14. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Please help me to do this project. Thanks

    Code:
    public static int convertF(int Fahrenheit) {
        return (Fahrenheit-32)*(5.0/9.0);
    }
    
    public static int convertC(int Celcius) {
        return (Celcius * (9.0/5.0)) + 32;
    }
    
    public static void Example(String text) {
        System.out.println(text);
    }
    That demonstrates returning. Notice how the bottom method doesn't have a "return" statement in its block of code? Thats because its a void, and voids don't return anything. Sort of like Subs in Visual Basic.

    Now see these:

    Code:
    public static int convertF(int Fahrenheit)
    public static int convertC(int Celcius)
    public static void Example(String text)
    These are the methods' signatures. Inside the parenthesis - ( and ) - Those are the parameters. As I said earlier, the parameters specify what arguments should be passed to the method.

    Now to demonstrate arguments, I must use these methods, so inside the Main() method, I would do this:
    Code:
    int C = ConvertF(90);
    int F = ConvertC(32);
    Example("Hello! This is an example of a method with a return type of 'void'!");
    Now notice the 90 inside the parenthesis next to ConvertF, and the 32 in the parenthesis in ConvertC. These numbers are the data passed to each function. They are the arguments. This is the same for the text in the speech marks inside the paranthesis of Example(). "Hello! This is an example of a method with a return type of 'void'!" is also an argument.

    AWT and Swing are best understood by studying, and the code to make a GUI application using AWT/Swing takes many lines of code, so I can't really demonstrate in this post I'm affraid.
     
  15. Unread #8 - Oct 1, 2007 at 1:29 PM
  16. Olan14
    Joined:
    Jan 26, 2007
    Posts:
    581
    Referrals:
    0
    Sythe Gold:
    0

    Olan14 Forum Addict

    Please help me to do this project. Thanks

    I began at 9. Learned Java, VB 2005, C#, JavaScript, VB6, and some C++. I've been learning Java since I was 9.
     
< C++: Adding repeat/until functionality | HTML Downloader >

Users viewing this thread
1 guest


 
 
Adblock breaks this site