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: Need some advice URGENT! thanks!!

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

    Default Need some advice URGENT! thanks!!

    hey everyone,
    i need to know whats missing to do to be able to
    initialise my program such that i can have this possible run

    ImageShack® - Online Photo and Video Hosting

    heres the code:
    import java.util.*;
     
    public class Resistance {
     
    	static Scanner input = new Scanner(System.in).useDelimiter("\r\n");
     
        public static void main(String[] args) {
        	double r1 = 0, r2 = 0, r3 = 0, rTotal = 0, rTotalpara = 0;
            int choice;
            int choice2;
            int loop = 0;
            while(loop < 10)
            {
            System.out.println("          Resistance Calculation            ");
        	System.out.println("          ======================            ");
            System.out.println("1> Resistance in Series  ");
            System.out.println("2> Resistance in Parallel");
            System.out.println("3> Exit                  ");
            System.out.println("=========================");
            System.out.print("Select your choice : ");
            choice = input.nextInt();
     
     
            System.out.println("2> 2 resistances: ");
            System.out.println("3> 3 resistances: ");
            System.out.print("Enter the number of resistance: ");
            choice = input.nextInt();
     
     
           switch (choice)
            {
            	case 2: rTotal = r1 + r2;
            		    System.out.print("Enter the FIRST resistance <ohm> : ");
            	        r1 = input.nextDouble();
            	        System.out.print("Enter the SECOND resistance <ohm> : ");
            	        r2 = input.nextDouble();
            	        System.out.println("----------------------------------------------------------------");
            		    System.out.println("Resultant resistance of the 2 resistors in Series = " + (r1 + r2));
                        break;
     
            	case 3: rTotal = r1 + r2;
            		    System.out.print("Enter the FIRST resistance <ohm> : ");
            	        r1 = input.nextDouble();
            	        System.out.print("Enter the SECOND resistance <ohm> : ");
            	        r2 = input.nextDouble();
            	        System.out.print("Enter the THIRD resistance <ohm> : ");
            	        r3 = input.nextDouble();
            	        System.out.println("----------------------------------------------------------------");
            		    System.out.println("Resultant resistance of the 3 resistors in Series = " + (r1 + r2 + r3));
            			break;
            	case 4: rTotalpara = (r1*r2)/(r1+r2);
            		   System.out.print("Enter the FIRST resistance <ohm> : ");
            	       r1 = input.nextDouble();
            	       System.out.print("Enter the SECOND resistance <ohm> : ");
            	       r2 = input.nextDouble();
            	       System.out.println("----------------------------------------------------------------");
            		   System.out.println("Resultant resistance of the 2 resistors in Parallel = " + ((r1*r2)/(r1+r2)));
                       break;
                case 5: rTotalpara = (r1*r2*r3)/(r2*r3+r1*r3+r1*r2);
            		   System.out.print("Enter the FIRST resistance <ohm> : ");
            	       r1 = input.nextDouble();
            	       System.out.print("Enter the SECOND resistance <ohm> : ");
            	       r2 = input.nextDouble();
            	       System.out.print("Enter the THIRD resistance <ohm> : ");
            	       r3 = input.nextDouble();
            	       System.out.println("----------------------------------------------------------------");
            		   System.out.println("Resultant resistance of the 3 resistors in Parallel = " + ((r1*r2*r3)/(r2*r3+r1*r3+r1*r2)));
            		   break;
     
            	default : System.out.println("Error");
            }System.out.println("");
            loop++;
            }
        }
    }
    Attached Images Attached Images


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,606
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Need some advice URGENT! thanks!!

    That's not really how this works. People hesitate to click external links. And did you seriously just take a picture of your homework assignment?

    If you want help, ask a specific question. What is your program doing? What do you expect it to do? What happens when you step through it with a debugger?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Need some serious advice
    By Rituparna in forum The Cafe
    Replies: 4
    Last Post: September 25th, 2013, 09:26 AM
  2. need for some advice
    By kasiopi in forum AWT / Java Swing
    Replies: 6
    Last Post: January 26th, 2011, 10:34 AM
  3. A little advice please:
    By SDKC in forum Java Theory & Questions
    Replies: 1
    Last Post: December 8th, 2010, 08:15 PM
  4. Need some help/advice for my GUI code.
    By J-Ark in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 4th, 2010, 01:23 PM
  5. i need some advice ....
    By mdstrauss in forum Java Theory & Questions
    Replies: 8
    Last Post: July 24th, 2009, 03:29 PM