Initial commit

This commit is contained in:
LinlyBoi
2022-01-27 19:21:54 +02:00
commit 8e447756ac
22 changed files with 710 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package Emploice;
public class Employees
{
String lastName;
String firstName;
double hourlyWage;
int yearsWithCompany;
public Employees()
{
}
public Employees(int years)
{
this.yearsWithCompany = years;
}
@Override
public String toString()
{
return "First Name: " + firstName + "\nLast name: " + lastName + "\nHourly wage: " + hourlyWage + "\nYears with company: " + yearsWithCompany;
}
public int getYears()
{
return yearsWithCompany;
}
}

View File

@@ -0,0 +1,24 @@
package Emploice;
import java.util.Random;
public class Programs
{
public static void main(String[] args)
{
Employees[] employs = new Employees[100];
for(int j = 0; j < employs.length; j++)
{
Random r = new Random();
employs[j] = new Employees(r.nextInt(1,50));
}
for(int i = 0; i < employs.length; i++)
{
if(employs[i].getYears() >= 20)
System.out.println(employs[i].toString());
}
}
}

View File

@@ -0,0 +1,45 @@
package IceCreamMachineStuff;
public class ChocolateIceCreamMachine extends IceCreamMachine
{
private double Cocoa;
private double CocoaConsumption;
public ChocolateIceCreamMachine(double creamconsumption,double sugarconsumption, double cocoaconsumption)
{
this.CocoaConsumption = cocoaconsumption;
this.SugarConsumption = sugarconsumption;
this.CreamConsumption = creamconsumption;
}
public void addMaterial(double cream,double sugar,double coca)
{
Cream += cream;
Sugar += sugar;
Cocoa += coca;
}
public double make(double amount)
{
double made = 0;
while(made < amount && Sugar >= SugarConsumption && Cream >= CreamConsumption && Cocoa >= CocoaConsumption)
{
made++;
Sugar -= SugarConsumption;
Cream -= CreamConsumption;
Cocoa -= CocoaConsumption;
}
Icecream += made;
return made;
}
@Override
public String toString()
{
return "No. of Cream: " + Cream + "\nNo. of IceCream: " + Icecream + "\n No. of sugar: " + Sugar + "\nNo. of Cocoa: " + Cocoa;
}
}

View File

@@ -0,0 +1,62 @@
package IceCreamMachineStuff;
public class IceCreamMachine
{
double Cream;
double Sugar;
double Icecream;
double SugarConsumption;
double CreamConsumption;
IceCreamMachine()
{
}
IceCreamMachine(double creamConsumption,double sugarConsumption)
{
this.CreamConsumption = creamConsumption;
this.SugarConsumption = sugarConsumption;
}
public void addMaterial(double cream,double sugar)
{
Sugar+=sugar;
Cream+=cream;
}
public double howMuch()
{
double C = Cream;
double S = Sugar;
double amount = 0;
while(C >= CreamConsumption && S >= SugarConsumption)
{
amount +=1;
C -= CreamConsumption;
S -= SugarConsumption;
}
return amount;
}
public double make(double amount)
{
double made = 0;
while(made < amount && Sugar >= SugarConsumption && Cream >= CreamConsumption)
{
made++;
Sugar -= SugarConsumption;
Cream -= CreamConsumption;
}
Icecream += made;
return made;
}
public double pack()
{
double packs = Math.rint(Icecream);
return packs;
}
@Override
public String toString()
{
return "No. of Cream: " + Cream + "\nNo. of IceCream: " + Icecream + "\n No. of sugar: " + Sugar;
}
}

View File

@@ -0,0 +1,15 @@
package IceCreamMachineStuff;
public class MainProgram
{
public static void main(String[] args)
{
ChocolateIceCreamMachine ChoccyGenerator = new ChocolateIceCreamMachine(10,5,3);
ChoccyGenerator.addMaterial(50,25,15);
ChoccyGenerator.make(4);
System.out.println("Amount in machine: " + ChoccyGenerator.pack());
System.out.println(ChoccyGenerator.toString());
}
}

BIN
src/Products/Product.class Normal file

Binary file not shown.

48
src/Products/Product.java Normal file
View File

@@ -0,0 +1,48 @@
package Products;
import java.util.Date;
public class Product
{
String pname;
double unitprice;
Date expdate = new Date();
Product()
{
}
Product(String name, double price, Date date)
{
this.pname = name;
this.unitprice = price;
this.expdate = date;
}
public boolean checkExpired()
{
Date today = new Date();
return expdate.before(today);
}
@Override
public String toString()
{
return "Product name: " + pname + "\nUnit price: " + unitprice + "\nExpiration date: " + expdate;
}
}

View File

@@ -0,0 +1,30 @@
package Products;
import java.util.Date;
public class ProductTests
{
public static void main(String[] args)
{
Date d1 = new Date(2025,10,10);
Date d2 = new Date(2021,10,10);
Date d3 = new Date(2020,10,10);
Product p1 = new Product("A0",100,d1);
Product p2 = new Product("A0",100,d2);
Product p3 = new Product("A0",100,d3);
if(p1.checkExpired() == false);
System.out.println("Pog");
if(p2.checkExpired()==true);
System.out.println("POG");
}
}

View File

@@ -0,0 +1,55 @@
package Questionaire;
import java.util.Scanner;
public class QuestionaireChecker
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter Number of students:");
int numberOfStudents = input.nextInt();
Student[] students = new Student[numberOfStudents];
for(int i = 0; i < students.length;i++)
{
System.out.println("enter answers for student " + (i+1));
students[i] = new Student();
students[i].answer();
System.out.println("Answers for student " + (i+1) + " filled");
}
int[] sameAnswers = checkanswers(students);
for(int k = 0; k < sameAnswers.length;k++)
{
if(sameAnswers[k] != 0)
System.out.println(sameAnswers[k]);
}
}
public static int[] checkanswers(Student[] students)
{
int[] questions = new int[25];
for(int i = 0; i < 25; i++)
{
boolean same = true;
int ans1 = students[0].ans[i];
for(int j = 1; j < students.length; j++)
{
if(ans1 != students[j].ans[i])
same = false;
}
if(same == true)
questions[i] = i+1;
}
return questions;
}
}

View File

@@ -0,0 +1,29 @@
package Questionaire;
import java.util.Scanner;
public class Student
{
public int[] ans = new int[25];
public void answer()
{
Scanner input = new Scanner(System.in);
for (int i = 0; i < 25;)
{
int in = input.nextInt();
if (in >= 1 && in <= 5)
{
ans[i] = in;
i++;
} else
System.out.println("invalid answer");
}
}
}

View File

@@ -0,0 +1,39 @@
package Savings;
public class SavingAccount
{
static double interest_rate = 0.10;
String id;
double amount;
SavingAccount(String Id,double Amount)
{
this.id = Id;
this.amount = Amount;
}
public double calc_profit()
{
double profit = amount * interest_rate;
amount+=profit;
return profit;
}
public static double getInterest()
{
return interest_rate;
}
public double getAmount()
{
return amount;
}
public static void setInterest_rate(double newInt)
{
interest_rate = newInt;
}
}

View File

@@ -0,0 +1,16 @@
package Savings;
public class SavingForm
{
public static void main(String[] args)
{
SavingAccount a1 = new SavingAccount("123asjkljr",500);
System.out.println("Balance is : "+ a1.getAmount() + " BEFORE profit");
double a1profit = a1.calc_profit();
System.out.println("Profit is : "+a1profit);
System.out.println("Balance is : "+a1.getAmount());
}
}

41
src/Student/Course.java Normal file
View File

@@ -0,0 +1,41 @@
package Student;
public class Course {
private String title;
private int Students;
private final int maxStudents = 10;
Student[] students = new Student[10];
int count = 0;
public String Register(Student student) {
if (count < 10) {
students[count] = student;
count++;
return "Success";
} else {
return "Course full!";
}
}
public boolean isFull()
{
if(count ==9)
return true;
else
return false;
}
public int NumberofStudents()
{
if(students[0].getName().isBlank())
return 0;
else
return count;
}
public String title()
{
return title;
}
}

30
src/Student/Student.java Normal file
View File

@@ -0,0 +1,30 @@
package Student;
public class Student
{
private String name;
private String id;
Student(String n, String Id)
{
this.name=n;
this.id=Id;
}
public String getName()
{
return name;
}
public String getId()
{
return id;
}
public void Register(Course course)
{
//To be done later
}
}

43
src/coffee/Batch.java Normal file
View File

@@ -0,0 +1,43 @@
package coffee;
public class Batch
{
int amount;
double price;
public int addBatch(int Takenout)
{
if(Takenout >= amount)
return amount;
if(amount == 0)
return 0;
amount-=Takenout;
return Takenout;
}
//ge4ta
public int getAmount()
{
return amount;
}
public int available()
{
return amount;
}
@Override
public String toString()
{
return "Amount in batch: " + amount + "\nTotal Price: " + price;
}
}

48
src/coffee/Coffee.java Normal file
View File

@@ -0,0 +1,48 @@
package coffee;
import java.util.Date;
import java.util.Stack;
public class Coffee extends Batch {
String name;
double price;
int stock;
Stack<Date> sold_records = new Stack<Date>();
Coffee() {
}
Coffee(String n, double p, int s) {
this.name = n;
this.price = p;
this.stock = s;
}
public void changePrice(double newprice) {
price = newprice;
}
public void prepare(int num) {
stock += num;
}
public void addStock(Batch batch,int amt)
{
prepare(batch.addBatch(amt));
}
public void sell(int num)
{
stock-=num;
sold_records.push(new Date());
}
@Override
public String toString()
{
return "Name: " + name + "\nPrice: " + price + "\nStock: "+ stock;
}
}