Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 50 additions & 18 deletions Area and Perimeter
Original file line number Diff line number Diff line change
@@ -1,26 +1,58 @@
// Java program to create a class to
// print the area and perimeter of a
// rectangle

import java.util.*;
class Question13
{

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

System.out.println("Enetr width::");
double width = sc.nextFloat();

System.out.println("Enetr height::");
double height = sc.nextFloat();

double perimeter = 2*(height + width);

double area = width * height;

System.out.println("Perimeter is:: "+ perimeter);
// Rectangle Class File
public class Rectangle {

// Variable of data type double
double length;
double width;

// Area Method to calculate the area of Rectangle
void Area()
{
double area;
area = this.length * this.width;
System.out.println("Area of rectangle is : "
+ area);
}

// Perimeter Method to calculate the Perimeter of
// Rectangle
void Perimeter()
{
double perimeter;
perimeter = 2 * (this.length + this.width);
System.out.println("Perimeter of rectangle is : "
+ perimeter);
}
}

class Use_Rectangle {

public static void main(String args[])
{
// Object of Rectangle class is created
Rectangle rect = new Rectangle();

// Assigning the value in the length variable of
// Rectangle Class
rect.length = 15.854;

System.out.println("Area is:: "+ area);
// Assigning the value in the width variable of
// Rectangle Class
rect.width = 22.65;


System.out.println("Length = " + rect.length);
System.out.println("Width = " + rect.width);

// Calling of Area method of Rectangle Class
rect.Area();

// Calling of Perimeter method of Rectangle Class
rect.Perimeter();
}
}
25 changes: 8 additions & 17 deletions Area and circumference of Circle
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import java.util.*;
class Question11{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

double pi = 3.14;
System.out.println("Enter Radius::");
double radius = sc.nextDouble();


System.out.println("Perimeter Is :: "+ 2* pi* radius );
System.out.println("Area Is ::"+ pi*radius * radius );

}
}
import math as m
r=float(input("Enter the radius of the circle:")) #radius of the circle
#Area of the circle
a = m.pi* r**2
#Circumference of the circle
c = 2 * m.pi * r
print("The area of the circle with radius {} is: {}".format(a,r))
print("The circumference of the circle with radius {} is {}".format(c,r))
174 changes: 113 additions & 61 deletions Calculator
Original file line number Diff line number Diff line change
@@ -1,66 +1,118 @@
import java.util.*;
class Calculator
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
float a, b; //a<=50000, b<=50000
int choice;
System.out.println("Enter two numbers:");
a = sc.nextFloat();
b = sc.nextFloat();
#Step1: Importing of the modules
from tkinter import *
#Step2: GUI Interection
win=Tk()
win.geometry("500x500")
#Step3: Adding Inputs
#entry box
e=Entry(win,width=56)
e.place(x=0,y=0)

if(a<=50000 && b<=50000)

#defining the numeric-functions:
def click(num):
result=e.get()
e.delete(0,END)
e.insert(0,str(result)+str(num))

#defining the operators:
def add():
n1=e.get()
global i
global a
a="addition"
i=int(n1)
e.delete(0,END)

{
System.out.println("Enter you choice");
System.out.println("1. Addition");
System.out.println("2. Subtraction");
System.out.println("3. Multiplication");
System.out.println("4. Division");
choice = sc.nextInt();
def sub():
n1=e.get()
global i
global a
a="substraction"
i=int(n1)
e.delete(0,END)

def mul():
n1=e.get()
global i
global a
a="multiplication"
i=int(n1)
e.delete(0,END)

def div():
n1=e.get()
global i
global a
a="division"
i=int(n1)
e.delete(0,END)

def empty():
e.delete(0,END)
global i
i=9
e.insert(0,i*0)

switch(choice)
{
case 1:
{
System.out.print(add(a, b));
break;
}
case 2:
{
System.out.print(sub(a, b));
break;
}
case 3:
{
System.out.print(mul(a, b));
break;
}
case 4:
{
System.out.print(div(a, b));
break;
}
}
}
System.out.println("\nInputs are not in range of 50000");
}
#difining the equal to function
def eql():
n2=e.get()
e.delete(0,END)
if a=="addition":
e.insert(0,i+int(n2))
elif a=="substraction":
e.insert(0,i-int(n2))
elif a=="multiplication":
e.insert(0, i*int(n2))
elif a=="division":
e.insert(0, i/int(n2))
elif a=="noip":
e.delete(0,END)
#Button first row
b=Button(win,text="7",width=12,command=lambda:click(7))
b.place(x=10,y=60)
b=Button(win,text="8",width=12,command=lambda:click(8))
b.place(x=80,y=60)
b=Button(win,text="9",width=12,command=lambda:click(9))
b.place(x=170,y=60)
b=Button(win,text="*",width=12,activebackground="yellow",command=mul)
b.place(x=240,y=60)

static float add(float x, float y)
{
return x+y;
}
static float sub(float x, float y)
{
return x-y;
}
static float mul(float x, float y)
{
return x*y;
}
static float div(float x, float y)
{
return x/y;
}
}
#Button 2nd row
b=Button(win,text="4",width=12,command=lambda:click(4))
b.place(x=10,y=90)
b=Button(win,text="5",width=12,command=lambda:click(5))
b.place(x=80,y=90)
b=Button(win,text="6",width=12,command=lambda:click(6))
b.place(x=160,y=90)
b=Button(win,text="+",width=12,activebackground="yellow",command=add)
b.place(x=240,y=90)

#button 3rd row
b=Button(win,text="1",width=12,command=lambda:click(1))
b.place(x=10,y=119)
b=Button(win,text="2",width=12,command=lambda:click(2))
b.place(x=80,y=119)
b=Button(win,text="3",width=12,command=lambda:click(3))
b.place(x=160,y=119)
b=Button(win,text="-",width=12,activebackground="yellow",command=sub)
b.place(x=240,y=119)

#Button 4th row
b=Button(win,text="AC",width=12,activebackground="red",command=empty)
b.place(x=10,y=149)
b=Button(win,text="0",width=12,command=lambda:click(0))
b.place(x=80,y=149)
b=Button(win,text="/",width=12,command=div)
b.place(x=160,y=149)
b=Button(win,text="=",width=12,activebackground="yellow",command=eql)
b.place(x=240,y=149)








win.mainloop()