Pages

Total Pageviews

Wednesday, June 5, 2019

Lab 3 Exercise Questions at Java Programming

import java.util.Scanner;

class labquestion1 {

   public static void main( String [] args) {
   
   Scanner scanner = new Scanner(System.in);
   scanner.useDelimiter ("!");
         
   System.out.print("Enter your string with an exclametion mark(!):");
   String first = scanner.next();
   String second = scanner.next();
       
   System.out.println(first);
   System.out.println(second); 
   
      }
  }   



import java.util.Scanner;

class labquestion2 {

   public static void main (String [] args) {
   
      double P,R,N, Amount;
      
      Scanner scanner = new Scanner(System.in);
      System.out.print ("Enter the Amount:");
      
      P = scanner.nextDouble();
      
      System.out.print("\n Enter the rate of interest:");
      
      R = scanner.nextDouble();
      
      System.out.print("\n Enter the number of years:");
      
      N = scanner.nextDouble();
      
      Amount = ( P*Math.pow((1+R/100), N));
      
      System.out.print ("\n The amount earned after"  +N+  "years is:" +Amount ); 
    
   }
}    




import java.util.Scanner;

class labquestion3 {

   public static void main (String [] args) {
    
      final double gravConst = 6.67*Math.pow(10, -11);
      final double massEarth = 5.98*Math.pow(10, 24);
      double rexp, rcoef, Satvelocity, radius;
      
      System.out.print ("Enter the coeffient value of the radius:");
      Scanner scanner = new Scanner(System.in);
      
      rcoef = scanner.nextDouble();
      
      System.out.print("Enter the explonent of the radius: ");
      
      rexp = scanner.nextDouble();
      radius = rcoef*Math.pow(10, rexp);
      
      System.out.println("The radius entered is: " + radius);
      
      Satvelocity = Math.sqrt ((gravConst*massEarth)/radius);
      
      System.out.println("The satellite velocity is: "+ Satvelocity+"m/s");
   }

No comments:

Post a Comment