Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package assingment;
- import java.util.Scanner;
- class uber{
- double TravelDistance;
- double PerkmPrice;
- int Promotion;
- uber(double a, double b, int c){
- TravelDistance=a;
- PerkmPrice=b;
- Promotion=c;
- }
- void Fare(){
- double cost;
- if(Promotion==1){
- cost=(TravelDistance * PerkmPrice)-(((TravelDistance * PerkmPrice)*10)/100);
- System.out.println("Total Cost : "+cost);
- }else{
- cost=TravelDistance * PerkmPrice;
- System.out.println("Total Cost : "+cost);
- }
- }
- }
- class Main{
- public static void main(String[] args){
- Scanner input= new Scanner(System.in);
- System.out.println("Enter Travel Distance in KM: ");
- double distance = input.nextDouble();
- System.out.println("Enter Price per KM: ");
- double price = input.nextDouble();
- System.out.println("Promotion Discount Active or Not press 1 or 0: ");
- int PActive= input.nextInt();
- uber use = new uber(distance, price, PActive);
- use.Fare();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement