Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners write java prgram

Have Programming Question? Ask it here!
 
 
 


aflah al mamari
write java prgram
1 Answer(s)      2 years and 3 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.


Advertisement
View Answers

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");
        System.out.println("Input your choice : ");
        choice=scanner.nextInt();
        switch(choice){
        case 1: System.out.println("Input radius of circle : ");
                float radius=scanner.nextFloat();
                float pi=(float) 3.14;
                float area=pi*radius*radius;
                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 .


Related Tutorials/Questions & Answers:
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
Advertisements
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 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 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
CREATE AND WRITE FILE THREAD JAVA
CREATE AND WRITE FILE THREAD JAVA  Hi guys I was wondering how can I make this program in java with threads. I need to create a file and write in it (i know how to do that) but by listening in some port all the data that is being
Java file read write operation
Java file read write operation  how to read and write the data from..."); oos.writeInt(8000); oos.writeObject("Ankit"); oos.writeObject("Java..."+sal1); for complete tutorial you can follow this link Java ObjectOutputStream
How to write a simple java applet
How to write a simple java applet   Hi, how can i write a simple java applet, displaying text in specific colors and font style. For example, the output will be something like : Name in red color Age in blue color Nationality
how to write this program? - Java Beginners
how to write this program?  (game:scissor,rock ,paper) A program that plays the sciccor-rock-paper game.Revise the program to let the user continuously play until either the user or the computer wins more than 4 times
Java Write To File - Java Tutorial
Java Write To File - Java Tutorial Learn how to write to a file from... on a FileOutputStream classes to write data to a file from Java program... of Java Tutorial you will learn how to write java program to write to a file. We
how to write the program - Java Beginners
how to write the program  WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects Lang Hindi History Geography Math Phy Chem. Bio Eve CSTA Also has a back up
How to Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java with the help of a sample Java program. After going though this tutorial you... to a file from Java program. To write the Java Write To File we will use two
Write a Java applet to draw cylinder and pentagon shapes.
Write a Java applet to draw cylinder and pentagon shapes.  Write a Java applet to draw cylinder and pentagon shapes
read/write to Windows Registry using Java
read/write to Windows Registry using Java  read/write to Windows Registry using Java
Java Write To File - Java Tutorial
of OutputStreamWriter class that is used to write text (as opposed to binary data... an internal FileOutputStream to write bytes to the specified file BufferedWriter : The BufferedWriter class is used to write text
How to write in Binary file in Java programming language
How to write in Binary file in Java programming language  I need some help about Java programming. Please explain me "How to write in Binary file in Java programming language
What is the best way to write to file in Java?
What is the best way to write to file in Java?  I am creating... to write to a text file in Java? Since my program will continuously write the data...;Read the tutorial at Java Write To File - Java Tutorial. Thanks
how to write to file from string in Java
how to write to file from string in Java  Hi, Please any one help me for how to write to file from string in Java. I am beginner in Java programming. Thanks,   Hi, Are you eager to learn how to write to file from
Java Write To InputStream
Java Write To InputStream In this tutorial you will learn how to write to InputStream in java. Write to file from InputStream in java you may use... a java program write simply on command prompt as : javac
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
How to write a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter... and strings. Example of how to write text to a file in java: import java.io.... will make a text file by the name "out.txt" and will write "Hello Java
write a java program to solve the infix expression
write a java program to solve the infix expression  ==>> solve the below expression using java program: 2+5*2-5+6/2 using stack operations or any other process in java
how to write tis java programming - Java Beginners
how to write tis java programming   Airport Transport Service...; displays the details of facility how to write tis program in java.....pls reply.... Using Transport.class and Facility.class, write a program that displays
How to write file from inputstream in java
link to your query "How to Write to inputStream in Java". This is good...How to write file from inputstream in java  Hi, how to write file from inputstream in java program. Plz suggest an example or suggested link
Advertisements
 

 

 

DMCA.com