-
Notifications
You must be signed in to change notification settings - Fork 0
Assignment_2 Added #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Naman1109
wants to merge
2
commits into
main
Choose a base branch
from
Assignment_2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| package Core_Java_Assignments; | ||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| class calculator { | ||
|
|
||
| void circle() { | ||
| System.out.println("Please Enter Radious"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please handle the exception if the number value is not in the correct format?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok sir |
||
| Scanner sc = new Scanner(System.in); | ||
| int r = sc.nextInt(); | ||
|
|
||
| System.out.println("Area Of circle is :" + 3.14 * (r * r)); | ||
| System.out.println("Perimeter Of Ciecle is :" + 2 * 3.14 * r); | ||
|
|
||
| } | ||
|
|
||
| void square() { | ||
|
|
||
| System.out.println("Please Enter Length"); | ||
| Scanner sc = new Scanner(System.in); | ||
| int a = sc.nextInt(); | ||
| System.out.println("Area Of Square is :" + a * a); | ||
| System.out.println("Perimeter Of Square is :" + 4 * a); | ||
| } | ||
|
|
||
| void traingle() { | ||
|
|
||
| System.out.println("Please Enter Hight"); | ||
| Scanner sc = new Scanner(System.in); | ||
| int th = sc.nextInt(); | ||
| System.out.println("Please Enter Base"); | ||
| int tb = sc.nextInt(); | ||
| System.out.println("Area Of Tringle is :" + 12 * tb * th); | ||
| System.out.println("Perimeter Of Tringle is :" + 12 * tb * th); | ||
| } | ||
|
|
||
| void cylinder() { | ||
| System.out.println("Please Enter Radious"); | ||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int cr = sc.nextInt(); | ||
| System.out.println("Please Enter Hight"); | ||
| int ch = sc.nextInt(); | ||
|
|
||
| System.out.println("Volume Of cylinder is :" + 3.14 * (cr * cr) * ch); | ||
| System.out.println("Susface Area Of cylinder is :" + 2 * 3.14 * cr * ch); | ||
| System.out.println("Area Of cylinder is :" + 2 * 3.14 * cr * (ch + cr)); | ||
|
|
||
| } | ||
|
|
||
| void rectangle() { | ||
| System.out.println("Please Enter Length"); | ||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int rec = sc.nextInt(); | ||
| System.out.println("Please Enter Breadth"); | ||
| int recb = sc.nextInt(); | ||
| System.out.println("Area Of rectangle is :" + rec * recb); | ||
| System.out.println("Perimeter Of rectangle is :" + 2 * (rec + recb)); | ||
| } | ||
|
|
||
| void cube() { | ||
| System.out.println("Please Enter Side"); | ||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int cube_l = sc.nextInt(); | ||
| System.out.println("Volume Of cube is :" + (cube_l * cube_l * cube_l)); | ||
| System.out.println("Susface Area Of cube is :" + 6 * (cube_l * cube_l)); | ||
| System.out.println("Perimeter Of cube is :" + 12 * (cube_l)); | ||
| } | ||
|
|
||
| void cuboid() { | ||
| System.out.println("Please Enter Length"); | ||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int cuboid_l = sc.nextInt(); | ||
| System.out.println("Please Enter Breadth"); | ||
| int cuboid_b = sc.nextInt(); | ||
| System.out.println("Please Enter Hight"); | ||
| int cuboid_h = sc.nextInt(); | ||
| System.out.println("Volume Of cuboid is :" + (cuboid_l * cuboid_b * cuboid_h)); | ||
| System.out.println("Susface Area Of cuboid is :" + 2 * ((cuboid_l * cuboid_b) + (cuboid_b * cuboid_h) + (cuboid_l * cuboid_h))); | ||
| System.out.println("Perimeter Of cuboid is :" + 4 * (cuboid_l + cuboid_b + cuboid_h)); | ||
|
|
||
| } | ||
|
|
||
| void tringle() { | ||
| System.out.println("Please Enter Hight"); | ||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int th = sc.nextInt(); | ||
| System.out.println("Please Enter Base"); | ||
| int tb = sc.nextInt(); | ||
| System.out.println("Area Of Tringle is :" + 12 * tb * th); | ||
| System.out.println("Perimeter Of Tringle is :" + 12 * tb * th); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public class Demo { | ||
|
|
||
| public static void main(String[] args) { | ||
| System.out.println("Dimension Calculator.."); | ||
| System.out.println("Menue..!"); | ||
| System.out.println("1. Circle"); | ||
| System.out.println("2. squre"); | ||
| System.out.println("3. cube"); | ||
| System.out.println("4. cuboid"); | ||
| System.out.println("5. Rectangle"); | ||
| System.out.println("6. tringle"); | ||
|
|
||
| System.out.println("Please Enter Choice...!"); | ||
| Scanner sc = new Scanner(System.in); | ||
| int i = sc.nextInt(); | ||
| calculator cal = new calculator(); | ||
|
|
||
| switch (i) { | ||
| case 1: | ||
| cal.circle(); | ||
| break; | ||
|
|
||
| case 2: | ||
| cal.square(); | ||
| break; | ||
|
|
||
| case 3: | ||
| cal.cube(); | ||
| break; | ||
| case 4: | ||
| cal.cuboid(); | ||
| break; | ||
| case 5: | ||
| cal.rectangle(); | ||
| break; | ||
| case 6: | ||
| cal.tringle(); | ||
| break; | ||
| default: | ||
| System.out.println("Invalid Option..!"); | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class name should be in the upper camel case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sir