Question: write java prgram

aflah al mamari
write java prgram
1 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners

write java program to offer a menu which contains 3 choices to make calculation on 3 shapes.use method for each calculation.

May 25, 2012 at 5:24 PM

```import java.util.Scanner;

public class CalculateAreaOfShapes{
public static void main(String []args){
int choice;
Scanner scanner=new Scanner(System.in);
System.out.println("1.For circle area.");
System.out.println("2.For square area ");
System.out.println("3.For Rectangle area");
choice=scanner.nextInt();
switch(choice){
case 1: System.out.println("Input radius of circle : ");
float pi=(float) 3.14;
System.out.println("Area of circle = "+area);
break;
case 2:System.out.println("Input side of square : ");
float length=scanner.nextFloat();
area=length*length;
System.out.println("Area of your square = "+area);
break;
case 3:System.out.println("Input length of rectangle : ");
length =scanner.nextFloat();
System.out.println("Input width of rectangle : ");
float width=scanner.nextFloat();
area=length*width;
System.out.println("Area of rectangle = "+area);
break;
default: System.out.println("Your choice is not correct.");
}
}
}
```

Description :Here we are calculating area of 3 shapes according to user choice. If user input 1 then we calculate circle area as Formula

```area of circle=3.14*radius*radius
```

If User's choice is 2 then your program give you output of square area. Formula of square-

```area of Square=length*width; where length and width are same
```

If choice is 3 then it will generate area of rectangle.Formula is -

```Area of rectangle = length*width .
```

write java prgram
write java prgram  write java program to offer a menu which contains 3 choices to make calculation on 3 shapes.use method for each calculation
write a java program
write a java program  write a program to print '*' in a circular form
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
write a programm using java
write a programm using java  print the following using java programming
Java write to file
Java write to file  How to write to a file in Java? Is there any good example code here? Thanks   Hi, Java is one of the best... files. You can easily use the the FileWriter and BufferedWriter to write data
write the java program?
write the java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
write the java program?
write the java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
Write a java application program........?
Write a java application program........?  Welcome every One : I have Q in Java? Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... to write in File of Java Program... the (BufferedReader) constructor. So that we write some data suing
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program?   Hi, For writing a file in Java, we need some classes from Java.IO... the Examples of How to write to File in Java Program: WriteToFileExample.java import
Write a program in java...
Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two... to enter an integer number. Write a program in java to find the factorial
help to write java code
help to write java code  write a full code to produce a system will calculate all items to get total carry-marks which are 60 marks. and get sum of assignment 1,assignment 2, midterms-test and lave work to get total marks
help to write java code
help to write java code  write a full code to produce a system will calculate all items to get total carry-marks which are 60 marks. and get sum of assignment 1,assignment 2, midterms-test and lave work to get total marks
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  How do I write a program in Java, have the program display a message with your name in it and a number (Hello john Smith!1) The number must increment from zero to nine, or decrement fron nine to zero. You
write program - Java Beginners
write program  write a java program that will read the values...]); } System.out.println(); } } } For more information on java visit to : http://www.roseindia.net/java/beginners/ Thanks
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  Write program which accepts five students id,name,age,department,courses, taken and its grade. a. calculate its GPA . display all student information in ascending order
Java Stream Write Exception
Java Stream Write Exception  I am doing socket programming. I have two files called Server.java and client.java. Both programs were running successfully and successfully sending data to each other. Yesterday I added the following
write a program in java.
write a program in java.  arrange the natural n umber in 5x5 matrix as 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 i at centerd position and remaining arrange in anticlockwise direction.
write a program - Java Beginners
write a program  1. write a program that reads a string composed of 6 words then generate and print a word composed of the first letters of the 6 words.  Hi friend, Code to solve the problem : class FirstLetter
Write short note on Java package.
Write short note on Java package.  Write short note on Java package
How to Write To File BufferedWriter in Java
How to Write To File BufferedWriter in Java  how to write to file bufferedwriter in Java   In Java there are 2 types of class files used... to write texts. In this classwe stores the character in a buffer to write
how to write java data - XML
how to write java data  how to write data to xml file  Hi friend, Read for more information, http://www.roseindia.net/xml/dom/ Thanks
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
How to write to xml file in Java?
How to write to xml file in Java?  Hi Friends, Can anyone help me how to write in xml file in Java programming. Please fill free to give example or reference website for getting example.   Hi, To write in xml file
how to write append file in Java
how to write append file in Java  How to write append file in Java... existing file should be retained when you are trying to write new contents in an existing files. For this in java program we uses WriteToFileAppend.java to be used
How to write into CSV file in Java
How to write into CSV file in Java  How to write into CSV file in Java   Hi, To create Comma separated value(CSV) file is very simple... passed the file name to write into a stream characters. Then we use the FileWriter
Java Write to File
Java Write to File In this tutorial you will learn how to write to file in java. Write to a file in java we are required to use some classes of java.io... doing the basic process to execute a java program write simply on command
Write a java pregram: Help with methods
Write a java pregram: Help with methods  Write a Java method that returns the number of days in a year using the following header: public static int numberOfDaysInAYear (int year) Write a Java program that uses your method
Tutorials