Jump to content

Java application help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
hoku_2000 _99

hoku_2000 _99

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
I am working on a Java application, but not too sure if I done it correctly. When I compile it, I have no errors.

Enter the over all length of the floor (in feet),Enter the over all width of the floor (in feet),Enter the radius of the floor (in feet), Enter the over all length of the floor (in feet), and Enter the prices of flooring material and logo material (per square feet). Calculate and display the total cost of the perimeter flooring and logo.

Formulas
area of a rectangle=length*width
area of a circle=PI*radius^2

I have to use methods from the Math class, use named constants for PI (3.1415) and the court size

Thanks to anyone who helps


------------------------------------------------------------------

import java.util.Scanner;


public class University

{


    public static void main (String[]args)

    {

        int length;

        int width;

        int price;

        int radius;

        int totalprice;



        Scanner scan=new Scanner(System.in);


        //Input from the user


        System.out.print("Enter the over all length of the floor (in feet): ");

        length=scan.nextInt();


        System.out.print("Enter the over all width of the floor (in feet): ");

        width=scan.nextInt();


        System.out.print("Enter the radius of the floor (in feet): ");

        radius=scan.nextInt();


        System.out.print("Enter the over all length of the floor (in feet): ");

        length=scan.nextInt();


        System.out.print("Enter the price of flooring: ");

        price=scan.nextInt();


        System.out.print("Enter the price of logo material: ");

        totalprice=scan.nextInt();


        //Calculate and display the total cost of the perimeter

        //flooring and logo.


        double area=Math.PI * Math.pow(radius,2);

        area=length*width;


      System.out.println("Total cost = $ " + totalprice + "." + area );

      System.out.println();


}

}

Attached Files


Edited by WingedPanther, 14 February 2009 - 07:38 AM.
add code tags (the # button)


#2
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
I don't know if this is how you wanted it.
Feeling generous to help out you so much that I made "what I believe is the task..."

Here you go !

import java.util.Scanner;

public class University	{

	static Scanner scan=new Scanner(System.in);

public static void main (String[]args) {

	int length;

	int width;

	int price1;

	int radius;

	int price2;

	

System.out.print("Enter the over all length of the floor (in feet): ");

	length=scan.nextInt();


System.out.print("Enter the over all width of the floor (in feet): ");

	width=scan.nextInt();


System.out.print("Enter the radius of the floor (in feet): ");

	radius=scan.nextInt();


System.out.print("Enter the price of flooring: ");

	price1=scan.nextInt();


System.out.print("Enter the price of logo material: ");

	price2=scan.nextInt();


double areaFlooring=length*width;

double areaLogo=Math.PI*(radius*radius);

int totalprice = price1+price2;


System.out.println("Cost of flooring: "+price1+" $"+" The area of the flooring: "+areaFlooring);

System.out.println("The area of the logo: "+areaLogo+" Cost of logo material: "+price2+" $");

System.out.println("Total cost: "+totalprice+" $");

	}

} 

Enjoy ;)
Posted Image

#3
hoku2000_99

hoku2000_99

    Newbie

  • Members
  • PipPip
  • 24 posts
Thanks for the help! :)