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: its crazy

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

    Default its crazy

    how do i get "its crazy" if gas goes past 4 in the avg?


    import java.util.Scanner;
     
    public class mk2
    {
    public static void main(String[] args)
    {
    new mk2 ();
    Scanner input = new Scanner( System.in );
     
          double total;
          double gasCounter;
          double gas = 0;
          double average;
     
          total = 0; 
          int valueCounter = 0;
     
          System.out.print( "  Enter gas price for octane 87, or -1 to quit: " );
          double value = input.nextDouble();
     
          while ( value != -1 )
          {
          total = total + value; 
          valueCounter = valueCounter + 1; 
     
     
          System.out.print( "Enter gas price for octane 89, or -1 to quit: " );
          value = input.nextDouble();
     
          while ( value != -1 )
          {
          total = total + value; 
          valueCounter = valueCounter + 1;
     
          System.out.print( "Enter gas price for octane 91, or -1 to quit: " );
          value = input.nextDouble();
          } 
     
     
          if ( valueCounter != 0 )
          {
          if ( gas>=4.00)
          {
        	 total = (double) total;
          }
          else if(value<4.00)
          {
        	  total = (double) total;
        	  }
        	  else
        	  {
        	  System.out.println("enter the valid ones");
        	  }
        	  }
     
        	  System.out.printf(" The average gas price is $%.3f\n", total/3);
     
          }
          }
     
    }
    public static void main(String[] args)
    {
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,330
    Thanks
    181
    Thanked 829 Times in 772 Posts
    Blog Entries
    5

    Default Re: its crazy

    I think you need to explain more the requirements you seek. Also, suggested reading: How To Ask Questions The Smart Way

Similar Threads

  1. Very basic program but its making me crazy
    By craig carl in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 2nd, 2011, 02:16 PM
  2. I'm sure it is really simple but it is driving me crazy
    By Ademske in forum AWT / Java Swing
    Replies: 2
    Last Post: January 17th, 2011, 06:41 AM
  3. Crazy array
    By javapenguin in forum What's Wrong With My Code?
    Replies: 18
    Last Post: June 26th, 2010, 03:02 AM
  4. [SOLVED] NullPointerException in Poker's program
    By dean_martin in forum Exceptions
    Replies: 10
    Last Post: April 21st, 2009, 06:40 AM