Advertisement
ariffyasri

Untitled

Oct 11th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.util.*;
  2. import java.text.*;
  3. public class cpromC {
  4.     public static void main(String [] args) {
  5.         Scanner scn = new Scanner(System.in);
  6.         while(scn.hasNext()) {
  7.             String accountNum = scn.next();
  8.             String custCode = scn.next();
  9.             char code = custCode.charAt(0);
  10.             double total = 0.0;
  11.             if(code == 'R' || code == 'r') {
  12.                 int numPremiumChannel = scn.nextInt();
  13.                 total = 25.00 + (numPremiumChannel * 7.5);
  14.             }
  15.             else if(code == 'B' || code == 'b') {
  16.                 int numPremiumChannel = scn.nextInt();
  17.                 int numBasicService = scn.nextInt();
  18.                 double basic = 0.0;
  19.                 if(numBasicService <= 10) {
  20.                     basic = 75.0;
  21.                 }
  22.                 else {
  23.                     basic = 75.0 + ((numBasicService-10)*5);
  24.                 }
  25.                 total = 15.0 + (50.0 * numPremiumChannel) + basic;
  26.             }
  27.             DecimalFormat df = new DecimalFormat("0.00");
  28.             System.out.println(accountNum +"\n" +df.format(total));
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement