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: difficulty with this code

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question difficulty with this code

    I'M having problems with code cant get it to work..

    I'm trying to read in 6 different weights representing the weights in kg of 6 different bags of flour from the keyboard.calculate the total weight and the average weight of the 6 bags of flour and print out the answers.
    i get 8 errors mostly incompatible type and cannot find symbol.


    import java.io.*;
     
    public class flourWeight{
    	//
    	//declare some variables and add values
    	//print the values back to the screen
    	//
     
    	public static void main(String[]args)throws IOException{
    		//declare some variables
     
     
     
    		double firstWeight ;
    		double secondWeight ;
    		double thirdWeight ;
    		double fourthWeight ;
    		double fifthWeight ;
    		double sixthWeight ;
     
    		double totalWeight=0 ;
    		double average ;
            double VAT;
     
     
           BufferedReader kbd=new BufferedReader(new InputStreamReader(System.in));;
     
           System.out.println("Enter the weight of the Six bags of flour?");
     
    		//Bellow i have printedthe first weight second weight ...
    		//double firstWeight ;
    		System.out.print("first weight= ");
    		firstWeight=kbd.readLine();
     
           // double secondWeight ;
    		System.out.print("Second Weight= ");
    		secondWeight=kbd.readLine();
     
            //double thirdWeight ;
    		System.out.print("third weight= ");
    		thirdWeight=kbd.readLine();
     
            //double fourthWeight;
    		System.out.print("fourth weight= ");
    		fourthWeight=kbd.readLine();
     
           // double fifthWeight ;
    		System.out.print("fifth weight= ");
    		fifthWeight=kbd.readLine();
     
           // double sixthWeight;
            System.out.print("sixth weight= ");
    		sixthWeight=kbd.readLine();
     
     
            totalWeight= (firstWeight + secondWeight + thirdWeight + fourthWeight + fifthWeight + sixthWeight);
            average = ( totalWeight) / 6;
     
     
    		//System.out.print(" sum of " + firstNumber + " and " + secondNumber + "and" + thirdNumber + "and" + fourthNumber " = " );
    		System.out.println("totalWeight : "+totalWeight);
             System.out.println(" Average : "+average);
             System.out.println("total priced as euros 3.50 per kg: "+totalWeight*3.50);
     
     
             if(totalWeight < 100)
             {  VAT = (total/100)*23;
     
    		 }
    		 if(totalWeight >= 100)
    		 { VAT = (total/100)*21;
     
    		 }
     
     
     
             //double total = 3.50;
    		// final double TAX_RATE = 8.5; // Tax rate in percent
    		 //double tax = total * TAX_RATE / 100; // tax is 0.2975
    		 //System.out.println("Total: " + total);
             //System.out.println("Tax: " + tax);
             //System.out.printf("Total:%5.2f", total);
     
    	}//end of main method
    }//end of class


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: difficulty with this code

    Format your code with syntax highliting, please.

    Does it make your TV blow up? Do you get compiler errors? Do you get runtime Exceptions? What does it do? What do you expect it to do?

Similar Threads

  1. Difficulty with understanding interaction between Classes
    By JBRPG in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 14th, 2012, 07:16 AM
  2. JScrollPane Difficulty. Help Please
    By AceApple in forum AWT / Java Swing
    Replies: 2
    Last Post: June 24th, 2012, 05:30 PM
  3. Difficulty with method headers.
    By tripline in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 30th, 2011, 10:58 AM
  4. [SOLVED] Difficulty with string passing...
    By Destined in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 12th, 2011, 05:43 AM