Chapter 1 Practise set

 

package com.company;
import java.util.Scanner;
import java.util.concurrent.atomic.DoubleAccumulator;
public class Practiceset1 {

  public static void main(String[] args) {
//Question 1 Calculate sum of 3 numbers
/*System.out.println("Sum of three numbers");
   float a,b,c,s;
System.out.println("First Number");
     Scanner sc = new Scanner(System.in);
      a = sc.nextFloat();
    System.out.println("Second Number");
     b = sc.nextFloat();
     System.out.println("Third Number");
     c = sc.nextFloat();
     s = a + b + c;
     System.out.println("The sum is");
      System.out.println(s);*/
 
  //Question 2 Calculate CGPA
    /*float subject1 = 82;
    float subject2 = 80;
    float subject3 = 85;
    float sum = (subject1 + subject2 + subject3)/30;
    System.out.print(cgpa);*/
   
   
    //Question 3 - ask for user name
    /*  System.out.println("What is your name?");
      Scanner sd = new Scanner(System.in);
      String name = sd.next();
      System.out.println("Hello "  +name+  " have a good day!");*/
     
      //Question 4 Convert KM to Miles
     
     /* System.out.println("Enter Kms");
      Scanner sm = new Scanner(System.in);
      Double km = sm.nextDouble();
      Double M = km*(.621371);
      System.out.println("Miles are:-");
      System.out.println(M);*/
     
      //Question 5 /check the number entered is an integer
     
     /* System.out.println("Enter your number");
      Scanner sc = new Scanner(System.in);
      System.out.println(sc.hasNextInt());
      */

Comments

Popular posts from this blog

Literals in Java

Percentage Calculator with user input