Oct 25, 2015

Exercise - PCP

Question 1:

Electricity usage charges as follows:-
     For the first 100 units – 35p/unit
     For the next 200 units – 50p/unit
     Beyond 300 units – 60p/unit.
Write a program that prompt 3 users by read the names of each users and number of units consumed and print out the charges with names.

Question 2:
By using repetition control structure, write a program that prompt for 5 student marks. Print out the grade for each students according to table below:

Marks                           Grade
80-100                              A  
 70-79                               B
 60-69                               C
 40-59                               D
  0-39                                F

Every student, please do this exercise to enhance your skills in programming. Our next lab session on Thursday, 5th November 2015.

Answer for Quiz 2

import java.util.Scanner;

public class Quiz2 {

public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner in = new Scanner (System.in);
double NormalPrice, DiscountAmount, NewPrice;
String PricingCode;


System.out.println("Pricing Code ----  Discount Rate");
System.out.println("      A                 50%     ");
System.out.println("      B                 40%     ");
System.out.println("      C                 33%     ");
System.out.println("      D                 25%     ");
System.out.println("      E                  0%     ");
System.out.print("\nBook price: RM");
NormalPrice = in.nextDouble();

System.out.print("Pricing code: ");
PricingCode = in.next();

if (PricingCode.equals("a") || PricingCode.equals("A"))
{
DiscountAmount = NormalPrice * 0.5;
NewPrice = NormalPrice - DiscountAmount;
System.out.println("Discount amount: RM " + DiscountAmount);
System.out.println("New Discounted Price: RM " + NewPrice);
}

else if (PricingCode.equals("b") || PricingCode.equals("B"))
{
DiscountAmount = NormalPrice * 0.4;
NewPrice = NormalPrice - DiscountAmount;
System.out.println("Discount amount: RM " + DiscountAmount);
System.out.println("New Discounted Price: RM " + NewPrice);
}

else if (PricingCode.equals("c") || PricingCode.equals("C"))
{
DiscountAmount = NormalPrice * 0.33;
NewPrice = NormalPrice - DiscountAmount;
System.out.println("Discount amount: RM " + DiscountAmount);
System.out.println("New Discounted Price: RM " + NewPrice);
}

else if (PricingCode.equals("d") || PricingCode.equals("D"))
{
DiscountAmount = NormalPrice * 0.25;
NewPrice = NormalPrice - DiscountAmount;
System.out.println("Discount amount: RM " + DiscountAmount);
System.out.println("New Discounted Price: RM " + NewPrice);
}

else if (PricingCode.equals("e") || PricingCode.equals("E"))
{
NewPrice = NormalPrice;
System.out.println("Discount amount: No Discount");
System.out.println("New Discounted Price: RM " + NewPrice);
}
else
{
System.out.println("Invalid pricing code");
}


}

}

Oct 19, 2015

QUIZ 1

Develop the followings solution algorithms for the given problems below:
1) IPO table
2) a pseudocode
3) a flowchart
4) Java coding

Create a class Temperature to convert Fahrenheit temperature to Kelvin.

 *Kelvin = (Fahrenheit + 459.67) * 5 / 9

Jul 27, 2015

Updated: 60% Carry Marks (Discrete Mathematics)

Assalamu'alaikum & Hi.

Selamat Hari Raya, Maaf Zahir Batin.

Good luck for your final exam, herewith is the 60% of your carry marks.



Jul 12, 2015

Notes (Discrete Mathematics)

Salam all.

Please download the following slide notes:
Counting Methods
Trees
Automata



Jun 24, 2015

Week 3 (Discrete Mathematics)

Please download the exercise here.
We will discuss the solution on Friday class, 26 June 2015 on 9am.


Jun 12, 2015

Week 2 (Discrete Mathematics)

Please download the notes here and exercise here.