├── AddSubImpl.java ├── Addition.java ├── Arithmatic.java ├── ArmstrongImpl.java ├── HelloWorld.java ├── Preettytable.java ├── StringB.java ├── Strings.class ├── Subtraction.java ├── Turtle_Star.java ├── TypCast.java ├── Variables.java ├── code.py.txt ├── factorial.java └── studentImpl.java /AddSubImpl.java: -------------------------------------------------------------------------------- 1 | import arithemeticop.*; 2 | class AddSubImpl{ 3 | public static void main(String[] args){ 4 | Addition a1=new Addition(4,3); 5 | a1.sum(); 6 | Subtraction s1=new Subtraction(5,4); 7 | s1.difference(); 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Addition.java: -------------------------------------------------------------------------------- 1 | package arithemeticop; 2 | public class Addition{ 3 | private int d1,d2; 4 | public Addition(int n1,int n2){ 5 | this.d1=n1; 6 | this.d2=n2; 7 | } 8 | public void sum() 9 | { 10 | System.out.println("sum of two given numbers is"+(d1+d2)); 11 | } 12 | } -------------------------------------------------------------------------------- /Arithmatic.java: -------------------------------------------------------------------------------- 1 | public class Arithmatic { 2 | public static void main(String[] args) { 3 | int a = 50, b = 5; 4 | System.out.println("Addition is " + (a + b)); 5 | System.out.println("Multiplication is " + (a * b)); 6 | System.out.println("Division is " + (a / b)); 7 | System.out.println("Substraction is " + (a - b)); 8 | System.out.println("Modulus is " + (a % b)); 9 | } 10 | } -------------------------------------------------------------------------------- /ArmstrongImpl.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class ArmstrongImpl { 3 | public static void main(String[] ar){ 4 | int sum=0,n,orn; 5 | Scanner sc=new Scanner(System.in); 6 | System.out.println("enetr the number."); 7 | n=sc.nextInt(); 8 | orn=n; 9 | while(orn!=10){ 10 | int rem=orn%10; 11 | sum+=rem*rem*rem; 12 | orn/=10; 13 | 14 | } 15 | if(sum==n){ 16 | System.out.println("armstrong number"); 17 | }else{ 18 | System.out.println("not armstrong number"); 19 | } 20 | sc.close(); 21 | } 22 | } -------------------------------------------------------------------------------- /HelloWorld.java: -------------------------------------------------------------------------------- 1 | public class HelloWorld { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Preettytable.java: -------------------------------------------------------------------------------- 1 | import prettytable as pt 2 | #Creating a prettytable object. 3 | table = pt.PrettyTable() 4 | table.add_column("Name",['Praveen','Omair','Yethishwar','Manoj','Prushotham']) 5 | table.add_column('Marks',[94,90,97,99,100]) 6 | table.align = 'l' #Alligned data to the left 7 | print(table) 8 | -------------------------------------------------------------------------------- /StringB.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class StringB{ 3 | public static void main(String[] args){ 4 | StringBuffer sb=new StringBuffer("study"); 5 | System.out.println(sb); 6 | sb.append("tonight"); 7 | System.out.println(sb); 8 | } 9 | } -------------------------------------------------------------------------------- /Strings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MushamPraveen13/JavaLabWorks/3cc9330e7a9c4c206f28714f5f85eb1239dd3a68/Strings.class -------------------------------------------------------------------------------- /Subtraction.java: -------------------------------------------------------------------------------- 1 | package arithemeticop; 2 | public class Subtraction{ 3 | private int d1,d2; 4 | public Subtraction(int n1,int n2){ 5 | this.d1=n1; 6 | this.d2=n2; 7 | } 8 | public void difference() 9 | { 10 | System.out.println("difference of two given numbers is"+(d1-d2)); 11 | } 12 | } -------------------------------------------------------------------------------- /Turtle_Star.java: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | # Set up the screen 4 | screen = turtle.Screen() 5 | screen.bgcolor("black") 6 | # Create a turtle object 7 | star = turtle.Turtle() 8 | star.color("yellow") 9 | 10 | def draw_star(size): 11 | for _ in range(5): 12 | star.forward(size) 13 | star.right(144) # angle for a star 14 | 15 | draw_star(100) 16 | turtle.done() -------------------------------------------------------------------------------- /TypCast.java: -------------------------------------------------------------------------------- 1 | class TypCast{ 2 | public static void main(String[] args) { 3 | int marks=80; 4 | long lmv=marks; 5 | System.out.println("integer value"+marks); 6 | System.out.println("long value"+lmv); 7 | 8 | /*float d=129.345; 9 | double inm=(double)d;*/ 10 | 11 | double d= 129.345; 12 | int inm=(int)d; 13 | 14 | System.out.println("double value"+d); 15 | System.out.println("integer value"+inm); 16 | } 17 | } -------------------------------------------------------------------------------- /Variables.java: -------------------------------------------------------------------------------- 1 | public class Variables { 2 | public static void main(String[] args) { 3 | 4 | //Primitive data types 5 | 6 | int Mynumber = 97; // ranging from -2,147,483,648 to 2,147,483,647. 7 | short Myshort = 830; //ranging from -32,768 to 32,767. 8 | long Mylong = 97723323; // ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. 9 | 10 | double Mydouble = 7.121121; 11 | float Myfloat = 3.45f; 12 | 13 | char Mychar = 'Y'; 14 | boolean Myboolean = true; 15 | 16 | byte Mybyte = 127; 17 | 18 | System.out.println(Mynumber); 19 | System.out.println(Myshort); 20 | System.out.println(Mylong); 21 | System.out.println(Mydouble); 22 | System.out.println(Myfloat); 23 | System.out.println(Mychar); 24 | System.out.println(Myboolean); 25 | System.out.println(Mybyte); 26 | } 27 | } -------------------------------------------------------------------------------- /code.py.txt: -------------------------------------------------------------------------------- 1 | import os 2 | def clear(): 3 | """Clears the console screen.""" 4 | os.system('cls' if os.name == 'nt' else 'clear') 5 | from Ascii_Art import logo 6 | print(logo) 7 | condition = True 8 | my_dict = {} 9 | while condition: 10 | name = input("What is your name?: ") 11 | bid_amount = int(input("What's your Bid amount: $")) 12 | my_dict[name] = bid_amount 13 | 14 | 15 | check = input("Are there any other bidders? Type 'Yes' or 'No': ").lower() 16 | if check == "yes": 17 | clear() 18 | elif check == "no": 19 | condition = False 20 | for (key,value) in my_dict.items(): 21 | max_value = max(my_dict.values()) 22 | for key,value in my_dict.items(): 23 | if value == max_value: 24 | print(f"The Winner is {key} with a bid of ${max_value}") 25 | else: 26 | print("You entered wrong option please try again!") 27 | 28 | #In above code intead of using .max() method we also have another way of approaching below 29 | ''' 30 | def find_highest_bidder(bidding_record): 31 | highest_bid = 0 32 | winner = "" 33 | # bidding_record = {"Angela": 123, "James": 321} 34 | for bidder in bidding_record: 35 | bid_amount = bidding_record[bidder] 36 | if bid_amount > highest_bid: 37 | highest_bid = bid_amount 38 | winner = bidder 39 | print(f"The winner is {winner} with a bid of ${highest_bid}") 40 | ''' -------------------------------------------------------------------------------- /factorial.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class factorial{ 3 | public static void main(String[] args) { 4 | int f=1; 5 | Scanner sc=new Scanner(System.in); 6 | System.out.println("enter the number to find the factorial"); 7 | int n=sc.nextInt(); 8 | for(int i=1;i<=n;i++){ 9 | f=f*i; 10 | } 11 | System.out.println("factorial of "+n+"is"+f); 12 | } 13 | } -------------------------------------------------------------------------------- /studentImpl.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class StudentImpl { 3 | public static void main(String[] args){ 4 | Student s= new Student("praveen","7094"); 5 | s.display(); 6 | } 7 | } 8 | class Student{ 9 | String nam,m; 10 | Student(String name,String rno){ 11 | nam=name; 12 | rn=rno; 13 | } 14 | public void display(){ 15 | System.out.printf("Welcome %s rno is %s \n",nam,rn); 16 | 17 | } 18 | } 19 | --------------------------------------------------------------------------------