Commit 6487a590 authored by Qazi Zain's avatar Qazi Zain

tasks are pushed

parent 80c3c8d0
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
/src/.idea
/src/javaTraining.iml
out/
javaTraining.iml
../out/production/javaTraining/Arrays/
../out/production/javaTraining/BankManagementSystem/
../out/production/javaTraining/Connditional_Statements/
../out/production/javaTraining/ExceptionHandling/
../out/production/javaTraining/Loops/
../out/production/javaTraining/Strings/
/src/out
\ No newline at end of file
out
/src/out
/src/.idea
/src/Class
/src/Constructors
/src/DataTypes
/src/ListInterface
/src/MapInterface
/src/Methods
/src/Syntax
/src/Variables
/src/javaTraining.iml
/out
\ No newline at end of file
package JavaTrainingTask.Question1;
import java.util.Scanner;
public class ImtiazStore {
int oilPrice;
int meetPrice;
int coldrinkPrice;
double bill;
int oil_quantity,meet_quantity,colddrink_quantity;
Scanner obj;
ImtiazStore() // constructor.
{
oilPrice= 500;
meetPrice=720;
coldrinkPrice=250;
bill=0;
System.out.println("Object is created");
obj = new Scanner(System.in);
}
//--------------------------------> setters <-------------------------------------
public void setColdrinkPrice(int coldrinkPrice) {
this.coldrinkPrice = coldrinkPrice;
}
public void setOilPrice(int oilPrice) {
this.oilPrice = oilPrice;
}
public void setMeetPrice(int meetPrice) {
this.meetPrice = meetPrice;
}
void displayItem()
{
System.out.println("Welcome to Imtiaz Super Store");
System.out.println("1.Oil price 500\n2.meet price 720\n3.Cold Drink price 250\n4. Exit");
}
void buyItems()
{
int choice;
boolean value= true;
while(value){
System.out.println("Enter the thing You Want to Purchase:");
choice = obj.nextInt();
switch(choice)
{
case 1:
System.out.println("Enter the liter of oil you want:");
oil_quantity = obj.nextInt();
bill+=(oilPrice*oil_quantity);
System.out.println("You have added: "+oil_quantity+" liter oil into cart");
break;
case 2:
System.out.println("Enter the kg of meet you want:");
meet_quantity = obj.nextInt();
System.out.println("You have added: "+meet_quantity+" kg meet into cart");
bill+=(meetPrice*meet_quantity);
break;
case 3:
System.out.println("Enter the no of cold drink bottel you want:");
colddrink_quantity = obj.nextInt();
System.out.println("You have added: "+colddrink_quantity+" no of cold drink bottels into cart");
bill+=(coldrinkPrice*colddrink_quantity);
break;
case 4:
System.out.println("Thank You For Shopping! Have a nice Day :)!");
value=false;
break;
default:
System.out.println("no such item found");
}
}
}
void displayBill()
{
System.out.println("liter of oil you purchased is:"+oil_quantity);
System.out.println("No of kg meet you purchased is:"+meet_quantity);
System.out.println("No of cold drink bottele you purchased is:"+colddrink_quantity);
if(bill>5000) {
double temp= bill*0.10;
bill-=temp;
System.out.println("you total bill after 10% discount is :" + bill);
}
else
{
System.out.println("you total bill is :" + bill);
}
}
void changeThePrice()
{
int option;
System.out.println("You can change the prices of items!\n1.change oil price:\n2.change meet price\n3.change cold drink price:");
option= obj.nextInt();
if(option==1)
{
System.out.println("Enter new price of Oil:");
int newPrice= obj.nextInt();
setOilPrice(newPrice);
}
else if(option==2)
{
System.out.println("Enter new price of Meet:");
int newprice= obj.nextInt();
setMeetPrice(newprice);
}
else if(option==3)
{
System.out.println("Enter new price of cold drink:");
int newprice= obj.nextInt();
setColdrinkPrice(newprice);
}
else{
System.out.println("No Change made!");
}
}
}
package JavaTrainingTask.Question1;
public class Main {
public static void main(String[] args) {
ImtiazStore obj = new ImtiazStore();
obj.displayItem();
obj.buyItems();
obj.displayBill();
obj.changeThePrice();
obj.buyItems();
obj.displayBill();
}
}
package JavaTrainingTask.Question2;
import java.util.Scanner;
public class Employee {
Scanner obj;
double HomeRentalAllowance,BasicSalary,DinningAllowance,grossSalary;
Employee()
{
System.out.println("Employee object");
obj= new Scanner(System.in);
HomeRentalAllowance=0;
BasicSalary=0;
DinningAllowance=0;
}
void grossSalaryCalculation()
{
System.out.println("Enter basic Salary:");
BasicSalary=obj.nextInt();
if(BasicSalary==15000)
{
HomeRentalAllowance=BasicSalary*0.10;
DinningAllowance= BasicSalary*0.90;
grossSalary = HomeRentalAllowance+DinningAllowance+BasicSalary;
System.out.println("Your HomeRental Allowance is :"+HomeRentalAllowance);
System.out.println("Your Dinning Allowance pay is :"+DinningAllowance);
System.out.println("Your gross pay is :"+grossSalary);
}
else if(BasicSalary>15000 && BasicSalary<20000)
{
HomeRentalAllowance= 500;
DinningAllowance = BasicSalary*0.98;
grossSalary = HomeRentalAllowance+DinningAllowance+BasicSalary;
System.out.println("Your HomeRental Allowance is :"+HomeRentalAllowance);
System.out.println("Your Dinning Allowance pay is :"+DinningAllowance);
System.out.println("Your gross pay is :"+grossSalary);
}
else
{
System.out.println("No calculation method is defined for this range salary yet!");
}
}
}
package JavaTrainingTask.Question2;
public class Main {
public static void main(String[] args)
{
Employee Zain = new Employee();
Zain.grossSalaryCalculation();
}
}
package JavaTrainingTask.Question3;
public class Main {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment