Skip to main content

Create one Box class and find out area and volume of a box (Using parameterized method, And method should have no return type)

Create one Box class and find out area and volume of a box (Using parameterized method, And method should have no return type).




import java.util.Scanner; 
public class volumeBox { 
public static void main(String[] args) { 
Scanner sc = new Scanner(System.in); 
System.out.println("Enter the value of length: "); 
double l=sc.nextDouble(); 
System.out.println("Enter the value of width: "); 
double w=sc.nextDouble(); 
System.out.println("Enter the value of height: "); 
double h=sc.nextDouble(); 
box b1=new box(); 
System.out.println("The area of the box is "+b1.area(l, w, h)); 
System.out.println("The volume of the box is "+b1.volume(l, w, h)); 
sc.close(); 
class box{ 
public double area(double l,double w,double h){ 
return 2*(l*w+l*h+h*w); 
public double volume(double l,double w,double h){ 
return l*w*h; 
}


OUTPUT:

Enter the value of length:
5
Enter the value of width:
6
Enter the value of height:
4
The area of the box is 148.0
The volume of the box is 120.0


Comments

Popular posts from this blog

Function Keys Shortcuts

Function Keys Shortcuts (F1 - F12) (Function Keys) F1 It is used to open the help window in almost all programs. Also used to enter BIOS or CMOS Some computers allow you to enter BIOS setup using different keys like F2, F10, Delete, Esc. Pressing Window + F1 will open the Microsoft Windows Help and Support Center. F2 In Microsoft Windows, it is used to rename an icon , file , or folder that the user selects. In Microsoft Excel, the F2 key allows you to edit the selected cell in the Excel sheet. In Microsoft Word, pressing Ctrl+F2 will open the print preview window and Alt+Ctrl+F2 will open the new file or document. In addition, it is also used to enter the CMOS setup. F3 It is mainly used to open a search function for many programs. At the MS-DOS or Windows command line, it gives users the option to repeat the last command entered. In Microsoft Word, if you press Shift + F3 , it allows you to change the selected text from uppercase to lowercase or a capital letter at the beginni...

Object Oriented and Relational Database

Object Relational and Object-Oriented Database What Is Object Relational Database? An object-relational database (ORD) is a database management system (DBMS) that’s composed of both a relational database (RDBMS) and an object-oriented database (OODBMS). An object-relational database acts as an interface between relational and object-oriented databases because it contains aspects and characteristics from both models. Object-oriented database (ORD) serves two main purposes: It connects the divide between relational databases and the object-oriented modeling techniques that are usually used in programming languages like C#, Java and C++. It bridges the gap between conceptual data modeling techniques for relational and object-oriented databases like entry-relationship diagram (ERD) and object-relational mapping (ORM). What Is Object Oriented Database? An object-oriented database is organized around objects rather than actions and data rather than logic. Therefore, an object database is a d...

Computer Fundamentals in Hindi

Computer Fundamentals in Hindi - कंप्यूटर फंडामेंटल्स हिंदी में - कंप्यूटर का परिचय कंप्यूटर शब्द अंग्रेजी के "Compute" शब्द से बना है, जिसका अर्थ है "गणना", करना होता है इसीलिए इसे गणक या संगणक भी कहा जाता है, इसका अबिस्कर Calculation करने के लिए हुआ था, पुराने समय में Computer का use केवल Calculation करने के लिए किया जाता था किन्तु आजकल इसका use डाक्‍यूमेन्‍ट बनाने, E-Mail, Listening And Viewing Audio And Video, Play Games, Database Preparation के साथ-साथ और कई कामों में किया जा रहा है, जैसे बैकों में, शैक्षणिक संस्‍थानों में, कार्यालयों में, घरों में, दुकानों में, Computer का उपयोग बहुतायत रूप से किया जा रहा है। Computer केवल वह करता है जो हम उसे करने का कहते हैं यानि केवल वह उन Command को फॉलो करता है जो पहले से Computer के अंदर डाले गए होते है, उसके अंदर सोचने समझने की क्षमता नहीं होती है, Computer को जो व्यक्ति चलता है उसे यूजर कहते है, और जो व्यक्ति Computer के लिए Program बनता है उसे Programmer  कहा जाता है। कंप्यूटर को ठीक प्रकार से कार्य करने के लिए सॉफ्टव...