pricepricecosti return price class Main public static void mainString args

Pricepricecosti return price class main public static

This preview shows page 39 - 43 out of 167 pages.

price=price+cost[i]; } } return price; } } class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); Mathios m=new Mathios(); int[] cost=new int[26]; for(int i=0;i<26;i++) { //cost[i]=sc.nextInt(); cost[i]=i; } int price=m.panagramChecker(m,cost); if(price!=0) { System.out.println("Inherited Papyrus is not panagram and the price to make it panagram is: "+price); } else { System.out.println("Ineherited String is a panagram"); } }
Image of page 39
} 2)A customer walks into a KFC outlet and sees that he has two options: veg and non-veg. He observes that plain veg burger costs 80/- and plain non-veg burger costs 120/- each. But he wishes to have extra mayonnaise and either of extra veggies/chicken on each of his burgers. Help the outlet by writing a program which’ll help them calculate the cost of the basic burger and also include the cost of the condiments if he chooses to add any. (Use Inheritance and Null Object Design Pattern) [L.O.6,7]Item Cost Mayonnaise 30/- Veggies 45/- Chicken 60/-
Image of page 40
3)Your local library needs your help related to library management and wants you to develop a program that will help them to calculate the fine .Remember that the name and the number of days the borrower had the book with them should be protected and display the information using inheritance concept .After 15 days fine will be charged as 2 rupees per day until the day of submission, if there is no charge simply print “NO FINE” else print the fine.[L.O.4]
Image of page 41
Scanner sc=new Scanner(System.in); System.out.println("Enter the name and the number of days book was with the borrower"); String name=sc.nextLine(); int n=sc.nextInt(); System.out.println("The name of the borrower :"+name); System.out.println("The number od books borrower had :"+n); if(n>1 5) { int t=n-15; int fine= t*2; System.out.println("FINE:"+f ine); } else { System.out.println("No fine"); } } } class Library extends Borrower { public static void main(String args[]) { Library lib = new Library(); lib. borrowerinfo(); } }
Image of page 42
Image of page 43

You've reached the end of your free preview.

Want to read all 167 pages?

  • Fall '19
  • Subroutine

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture