Created
May 24, 2017 02:57
-
-
Save PVaid/07265c3fee7019c583b237289a578cc9 to your computer and use it in GitHub Desktop.
Animal Love!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class DogRegistration | |
{ | |
public void processDogs() | |
{ double total_fees=0; | |
double total_discount = 0; | |
for(int i=0;i<3;i++) | |
{ | |
double fee, disct; | |
Scanner sc=new Scanner(System.in); | |
System.out.println("Welcome to Dog Registration Program"); | |
System.out.print("Enter the name of dog" +(i+1)+" ==>"); | |
String name=sc.nextLine(); | |
System.out.print("Enter the age of "+" " +name+ " "+"dog in years ==>"); | |
int age=sc.nextInt(); | |
System.out.println("Is "+name+ " "+"dog de-sexed (Y/N) ==>"); | |
String response=sc.next(); | |
fee = this.calculateFee(age, response); | |
total_fees+=fee; | |
System.out.print("Enter any additional discount as percentage ==>"); | |
double discount=sc.nextDouble(); | |
disct = this.calculateDiscount(fee, discount); | |
System.out.println("Statistic for dog"+name); | |
System.out.println("------------------------------------------------"); | |
System.out.println("Fee: "+fee); | |
System.out.println("Discounts: "+disct); | |
System.out.println("------------------------------------------------"); | |
total_discount+=disct; | |
} | |
finalOutput(total_fees, total_discount); | |
} | |
public double calculateFee(int age, String response) | |
{ | |
if(age>=10) | |
{ | |
return 15.00; | |
} | |
else if((age<10)&&response.equals("y")||response.equals("Y")) | |
{ | |
return 25.00; | |
} | |
else if((age<10)&&response.equals("n")||response.equals("N")) | |
{ | |
return 45.00; | |
} | |
return 0; | |
} | |
public double calculateDiscount(double rs, double discount) //error | |
{ | |
double discountCal=(rs*(discount/100)); | |
return (rs-discountCal); | |
} | |
public void finalOutput(double total_fees,double total_discount) | |
{ | |
System.out.println("Final statistics"); | |
System.out.println("------------------------------------------------"); | |
System.out.println("Total fees "+total_fees ); | |
System.out.println("Total discounts "+total_discount ); | |
System.out.println("------------------------------------------------"); | |
} | |
public static void main(String args[]) | |
{ | |
DogRegistration dogRegistration=new DogRegistration(); | |
dogRegistration.processDogs(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment