SlideShare a Scribd company logo
1 of 5
LAB 3
NUR IZZATUL BINTISAFINGAI(178969)
//Question 1
//NUR IZZATUL BINTI SAFINGAI(178969)
// BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER
// LAB 3
import java.util.Scanner;
public class PriceDiscount {
public static void main(String[] args) {
//declare variable
int numberItem;
double Price, afterDiscount;
//Create scanner and user input the data
Scanner p= new Scanner(System.in) ;
System.out.print("Enter number of item brought: ");
numberItem=p.nextInt();
System.out.print("Enter price of item: RM ");
Price=p.nextDouble();
//condition, the calculation of price after discount
//display the result
if ((numberItem >=1) && (numberItem <=9))
if ((Price >= 0.01) && (Price<= 10.0))
{
afterDiscount=(Price-(0 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if ((Price >= 10.01) && (Price<= 100.00))
{
afterDiscount=(Price-(0.02 * Price))*(numberItem);
System.out.println("The total price is RM "+ afterDiscount);
}
else if (Price== 100.01)
{
afterDiscount=(Price-(0.05 * Price))*(numberItem);
System.out.println("The total price is RM"+afterDiscount);
}
if((numberItem >=10) && (numberItem <=99))
if ((Price >= 0.01) && (Price<= 10.0))
{
afterDiscount=(Price-((0.05) * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if((Price >= 10.01) && (Price<= 100.00))
{
afterDiscount=(Price-(0.07 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if (Price ==100.01)
{
afterDiscount=(Price-(0.09 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
if((numberItem >=100) && (numberItem <=499))
if ((Price >= 0.01) && (Price<= 10.0))
{
afterDiscount=(Price-(0.09 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if((Price >= 10.01) && (Price<= 100.00))
{
afterDiscount=(Price-(0.15 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if (Price ==100.01){
afterDiscount=(Price-(0.21 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
if((numberItem >=500) && (numberItem <=999))
if ((Price >= 0.01) && (Price<= 10.0))
{
afterDiscount=(Price-(0.14 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if((Price >= 10.01) && (Price<= 100.00))
{
afterDiscount=(Price-(0.23 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if (Price ==100.01)
{
afterDiscount=(Price-(0.32 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
if(numberItem >=1000)
if ((Price >= 0.01) && (Price<= 10.0))
{
afterDiscount=(Price-(0.21 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if((Price >= 10.01) && (Price<= 100.00))
{
afterDiscount=(Price-(0.32 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
else if (Price ==100.01)
{
afterDiscount=(Price-(0.43 * Price))*(numberItem);
System.out.println("The total price is RM "+afterDiscount);
}
}
}
//Question 2
//NUR IZZATUL BINTI SAFINGAI(178969)
// BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER
// LAB 3
import java.util.Scanner;
public class VendingMachine {
public static void main(String[] args) {
//create scanner
Scanner p= new Scanner(System.in) ;
double p1 = 1.25;
double p2 = 0.75;
double p3 = 0.90;
double p4 = 0.75;
double p5 = 1.50;
double p6 = 0.75;
//Display the list of item with the price
System.out.println("List of item");
System.out.println("");
System.out.println("Item 1: "+p1);
System.out.println("Item 2: "+p2);
System.out.println("Item 3: "+p3);
System.out.println("Item 4: "+p4);
System.out.println("Item 5: "+p5);
System.out.println("Item 6: "+p6);
System.out.print("n");
//User enter data
System.out.print("Enter an item number: ");
int item_number= p.nextInt();
System.out.print("Enter the price: RM ");
double price= p.nextDouble();
System.out.print("Enter sum of money: RM ");
double sumMoney= p.nextDouble();
System.out.print("n");
//compute formula
double change=sumMoney-price;
double notEnough=price-sumMoney;
//Display the result based on user's input
if ((price ==sumMoney)||(sumMoney>price))
{
System.out.println("Enter an item number and sum of money:
"+item_number+" "+sumMoney);
System.out.println("Thank you for buying item "+item_number+".
Your change is RM "+change);
}
else
{
System.out.println("Enter an item number and sum of money:
"+item_number+" "+sumMoney);
System.out.print("Please insert another RM "+notEnough);
}
}
}
//Question 3
//NUR IZZATUL BINTI SAFINGAI(178969)
// BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER
// LAB 3
public class Menu {
public static void main(String[] args) {
double price= 4.99;
double price1= 2.00;
double price2= 1.00;
//Display the menu
System.out.println("1. Cheeseburger RM "+price);
System.out.println("2. Pepsi RM "+price1);
System.out.println("3. Fun Fries RM " +price2);
}
}
//Question 4
//NUR IZZATUL BINTI SAFINGAI(178969)
// BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER
// LAB 3
import java.util.Scanner;
public class WeeklyEmployee {
public static void main(String[] args) {
double net_pay;
String name;//Declare variable
Scanner input=new Scanner(System.in);
System.out.print("Employee name: ");
name=input.next();
int hours_work;//Declare variable
Scanner input1=new Scanner(System.in);
System.out.print("Hours per week: ");
hours_work=input1.nextInt();
int wage_rate;//declare variable
Scanner input2=new Scanner(System.in);
System.out.print("Hourly wage rate: ");
wage_rate=input2.nextInt();
System.out.println("n");
if (hours_work <= 40)
{
//compute formula
double gross_pay= hours_work*wage_rate;
net_pay=gross_pay-((3.625/100)*gross_pay);
//Display the result
System.out.println("Employee: "+name);
System.out.println("Gross pay: "+gross_pay);
System.out.println("Net pay: "+net_pay);
}
else if (hours_work> 40)
{
//compute formula
double over_hours=((hours_work-40)*wage_rate);
double gross_pay=(0.5*over_hours)+over_hours+40;
net_pay=gross_pay-((3.625/100)*gross_pay);
//Display the result
System.out.println("Employee: "+name);
System.out.println("Gross pay: "+gross_pay);
System.out.println("Net pay: "+net_pay);
}
}
}

More Related Content

What's hot

Example of JAVA Program
Example of JAVA ProgramExample of JAVA Program
Example of JAVA ProgramTrenton Asbury
 
Java this keyword ppt with example
Java this keyword ppt with exampleJava this keyword ppt with example
Java this keyword ppt with examplePavan b
 
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)Sylvain Hallé
 
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)Sylvain Hallé
 
Practice programs
Practice programsPractice programs
Practice programsAbbott
 
When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)Sylvain Hallé
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Sylvain Hallé
 
Throttle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web AppsThrottle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web AppsAlmir Filho
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2vikram mahendra
 

What's hot (20)

week-16x
week-16xweek-16x
week-16x
 
Uts
UtsUts
Uts
 
Applet
AppletApplet
Applet
 
Node js
Node jsNode js
Node js
 
Example of JAVA Program
Example of JAVA ProgramExample of JAVA Program
Example of JAVA Program
 
Java this keyword ppt with example
Java this keyword ppt with exampleJava this keyword ppt with example
Java this keyword ppt with example
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Semaphore
SemaphoreSemaphore
Semaphore
 
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
 
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
 
Practice programs
Practice programsPractice programs
Practice programs
 
When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)
 
Ext oo
Ext ooExt oo
Ext oo
 
Java file
Java fileJava file
Java file
 
programming for Calculator in java
programming for Calculator in javaprogramming for Calculator in java
programming for Calculator in java
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
 
Throttle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web AppsThrottle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web Apps
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
Calculator
CalculatorCalculator
Calculator
 

Viewers also liked (17)

3 bitna sastanka 19 veka
3 bitna sastanka 19 veka3 bitna sastanka 19 veka
3 bitna sastanka 19 veka
 
DWA Drug Testing Program
DWA Drug Testing ProgramDWA Drug Testing Program
DWA Drug Testing Program
 
Selena gomez
Selena gomezSelena gomez
Selena gomez
 
Vitamins
VitaminsVitamins
Vitamins
 
El gran dictat
El gran dictatEl gran dictat
El gran dictat
 
Automate data warehouse etl testing and migration testing the agile way
Automate data warehouse etl testing and migration testing the agile wayAutomate data warehouse etl testing and migration testing the agile way
Automate data warehouse etl testing and migration testing the agile way
 
Prvi svetski rat u srbiji
Prvi svetski rat u srbijiPrvi svetski rat u srbiji
Prvi svetski rat u srbiji
 
Castanyers
CastanyersCastanyers
Castanyers
 
Power llucia i_sara_2
Power llucia i_sara_2Power llucia i_sara_2
Power llucia i_sara_2
 
Presentación1
Presentación1Presentación1
Presentación1
 
Penglibatanibubapa 121009233029-phpapp02
Penglibatanibubapa 121009233029-phpapp02Penglibatanibubapa 121009233029-phpapp02
Penglibatanibubapa 121009233029-phpapp02
 
Erp
ErpErp
Erp
 
Presentation
PresentationPresentation
Presentation
 
Presentatie levels 2012 def
Presentatie levels 2012 defPresentatie levels 2012 def
Presentatie levels 2012 def
 
Dramas coreanos
Dramas coreanosDramas coreanos
Dramas coreanos
 
наполеон
наполеоннаполеон
наполеон
 
8 razred jugoslavija kraljevina shs 1918 1929
8 razred jugoslavija kraljevina shs 1918 19298 razred jugoslavija kraljevina shs 1918 1929
8 razred jugoslavija kraljevina shs 1918 1929
 

Similar to Lab 3

Import java
Import javaImport java
Import javaheni2121
 
AnswerNote programming specifications and the printing statement.pdf
AnswerNote programming specifications and the printing statement.pdfAnswerNote programming specifications and the printing statement.pdf
AnswerNote programming specifications and the printing statement.pdfanushasarees
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfAnkitchhabra28
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdfangelsfashion1
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerAiman Hud
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfatulkapoor33
 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Sunil Kumar Gunasekaran
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
การหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึมการหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึมPairy Little
 
Star pattern programs in java Print Star pattern in java and print triangle ...
Star pattern programs in java Print Star pattern in java and  print triangle ...Star pattern programs in java Print Star pattern in java and  print triangle ...
Star pattern programs in java Print Star pattern in java and print triangle ...Hiraniahmad
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docxKatecate1
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfarihantmum
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specificationsrajkumari873
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2Ankit Gupta
 
#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdfsrinivas9922
 
when I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docxwhen I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docxlashandaotley
 

Similar to Lab 3 (19)

Import java
Import javaImport java
Import java
 
AnswerNote programming specifications and the printing statement.pdf
AnswerNote programming specifications and the printing statement.pdfAnswerNote programming specifications and the printing statement.pdf
AnswerNote programming specifications and the printing statement.pdf
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
 
Java file
Java fileJava file
Java file
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdf
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
การหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึมการหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึม
 
Star pattern programs in java Print Star pattern in java and print triangle ...
Star pattern programs in java Print Star pattern in java and  print triangle ...Star pattern programs in java Print Star pattern in java and  print triangle ...
Star pattern programs in java Print Star pattern in java and print triangle ...
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docx
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2
 
#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf
 
when I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docxwhen I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docx
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Lab 3

  • 1. LAB 3 NUR IZZATUL BINTISAFINGAI(178969) //Question 1 //NUR IZZATUL BINTI SAFINGAI(178969) // BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER // LAB 3 import java.util.Scanner; public class PriceDiscount { public static void main(String[] args) { //declare variable int numberItem; double Price, afterDiscount; //Create scanner and user input the data Scanner p= new Scanner(System.in) ; System.out.print("Enter number of item brought: "); numberItem=p.nextInt(); System.out.print("Enter price of item: RM "); Price=p.nextDouble(); //condition, the calculation of price after discount //display the result if ((numberItem >=1) && (numberItem <=9)) if ((Price >= 0.01) && (Price<= 10.0)) { afterDiscount=(Price-(0 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } else if ((Price >= 10.01) && (Price<= 100.00)) { afterDiscount=(Price-(0.02 * Price))*(numberItem); System.out.println("The total price is RM "+ afterDiscount); } else if (Price== 100.01) { afterDiscount=(Price-(0.05 * Price))*(numberItem); System.out.println("The total price is RM"+afterDiscount); } if((numberItem >=10) && (numberItem <=99)) if ((Price >= 0.01) && (Price<= 10.0)) { afterDiscount=(Price-((0.05) * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); }
  • 2. else if((Price >= 10.01) && (Price<= 100.00)) { afterDiscount=(Price-(0.07 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } else if (Price ==100.01) { afterDiscount=(Price-(0.09 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } if((numberItem >=100) && (numberItem <=499)) if ((Price >= 0.01) && (Price<= 10.0)) { afterDiscount=(Price-(0.09 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } else if((Price >= 10.01) && (Price<= 100.00)) { afterDiscount=(Price-(0.15 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } else if (Price ==100.01){ afterDiscount=(Price-(0.21 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } if((numberItem >=500) && (numberItem <=999)) if ((Price >= 0.01) && (Price<= 10.0)) { afterDiscount=(Price-(0.14 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } else if((Price >= 10.01) && (Price<= 100.00)) { afterDiscount=(Price-(0.23 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } else if (Price ==100.01) { afterDiscount=(Price-(0.32 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } if(numberItem >=1000) if ((Price >= 0.01) && (Price<= 10.0)) { afterDiscount=(Price-(0.21 * Price))*(numberItem);
  • 3. System.out.println("The total price is RM "+afterDiscount); } else if((Price >= 10.01) && (Price<= 100.00)) { afterDiscount=(Price-(0.32 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } else if (Price ==100.01) { afterDiscount=(Price-(0.43 * Price))*(numberItem); System.out.println("The total price is RM "+afterDiscount); } } } //Question 2 //NUR IZZATUL BINTI SAFINGAI(178969) // BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER // LAB 3 import java.util.Scanner; public class VendingMachine { public static void main(String[] args) { //create scanner Scanner p= new Scanner(System.in) ; double p1 = 1.25; double p2 = 0.75; double p3 = 0.90; double p4 = 0.75; double p5 = 1.50; double p6 = 0.75; //Display the list of item with the price System.out.println("List of item"); System.out.println(""); System.out.println("Item 1: "+p1); System.out.println("Item 2: "+p2); System.out.println("Item 3: "+p3); System.out.println("Item 4: "+p4); System.out.println("Item 5: "+p5); System.out.println("Item 6: "+p6); System.out.print("n"); //User enter data System.out.print("Enter an item number: "); int item_number= p.nextInt(); System.out.print("Enter the price: RM "); double price= p.nextDouble(); System.out.print("Enter sum of money: RM "); double sumMoney= p.nextDouble();
  • 4. System.out.print("n"); //compute formula double change=sumMoney-price; double notEnough=price-sumMoney; //Display the result based on user's input if ((price ==sumMoney)||(sumMoney>price)) { System.out.println("Enter an item number and sum of money: "+item_number+" "+sumMoney); System.out.println("Thank you for buying item "+item_number+". Your change is RM "+change); } else { System.out.println("Enter an item number and sum of money: "+item_number+" "+sumMoney); System.out.print("Please insert another RM "+notEnough); } } } //Question 3 //NUR IZZATUL BINTI SAFINGAI(178969) // BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER // LAB 3 public class Menu { public static void main(String[] args) { double price= 4.99; double price1= 2.00; double price2= 1.00; //Display the menu System.out.println("1. Cheeseburger RM "+price); System.out.println("2. Pepsi RM "+price1); System.out.println("3. Fun Fries RM " +price2); } }
  • 5. //Question 4 //NUR IZZATUL BINTI SAFINGAI(178969) // BACELOR SAINS KOMPUTER PENGKHUSUSAN SISTEM KOMPUTER // LAB 3 import java.util.Scanner; public class WeeklyEmployee { public static void main(String[] args) { double net_pay; String name;//Declare variable Scanner input=new Scanner(System.in); System.out.print("Employee name: "); name=input.next(); int hours_work;//Declare variable Scanner input1=new Scanner(System.in); System.out.print("Hours per week: "); hours_work=input1.nextInt(); int wage_rate;//declare variable Scanner input2=new Scanner(System.in); System.out.print("Hourly wage rate: "); wage_rate=input2.nextInt(); System.out.println("n"); if (hours_work <= 40) { //compute formula double gross_pay= hours_work*wage_rate; net_pay=gross_pay-((3.625/100)*gross_pay); //Display the result System.out.println("Employee: "+name); System.out.println("Gross pay: "+gross_pay); System.out.println("Net pay: "+net_pay); } else if (hours_work> 40) { //compute formula double over_hours=((hours_work-40)*wage_rate); double gross_pay=(0.5*over_hours)+over_hours+40; net_pay=gross_pay-((3.625/100)*gross_pay); //Display the result System.out.println("Employee: "+name); System.out.println("Gross pay: "+gross_pay); System.out.println("Net pay: "+net_pay); } } }