Page 134 - ComputerScience_Class_11
P. 134

F.  Write the java program for the following:
                  1.  Write a program to input the principal amount, rate of interest and time and then calculate the compound interest.
                     The program should produce the following output:
                     Enter the principal amount: 1000
                     Enter the rate of interest: 5
                     Enter the time (in years): 5
                     The compound interest is: 276.281582500003
                  2.  Write a program to input two integer numbers and print their multiplication.
                     The program should produce the following output:
                     Enter the first integer: 5
                     Enter the second integer: 6
                     The multiplication of 5 and 6 is: 30
                  3.  Write a program to input the radius of a circle and calculate its area.
                     The output should be as follows:
                     Enter the radius of the circle: 7
                     Radius: 7.0
                     Area of the circle: 153.86
              G.  Find the output of the following programs:
                  1.  class Triangle {

                        int base, height, area;
                        void calculateArea() {
                            area = (base * height) / 2;

                        }
                        public static void main(String[] args) {
                            Triangle t = new Triangle();
                            t.base = 5;
                            t.height = 4;
                            t.calculateArea();
                            System.out.println("Area of the triangle: " + t.area);  // Output the calculated area
                        }
                    }
                  2.  import java.util.Scanner;

                    class Circle {
                          double radius, circumference;
                          void calculateCircumference() {
                              circumference = 2 * Math.PI * radius;
                          }
                          void display() {

                              System.out.println("Radius: " + radius);
                              System.out.println("Circumference of the circle: " + circumference);
                          }
                          public static void main(String[] args) {




                  132  Touchpad Computer Science (Ver. 3.0)-XI
   129   130   131   132   133   134   135   136   137   138   139