java exercise 1

//Complete Java Course Exercise 1: Percentage calculator in Java
//  students in boad exam marks from 5 subjecttakes as input from keyword marks are out of


package com.company;
import java.util.Scanner;


public class cwh_06_exercise1_calculate_percentage {


    public static void main(String[] args){

                int total, score;
                float percentage;
                Scanner inputNumScanner = new Scanner(System.in);

                System.out.println("Enter the total, or max, score: ");
                total = inputNumScanner.nextInt();

                System.out.println("Enter the score obtained: ");
                score = inputNumScanner.nextInt();

                percentage = (score * 100/ total);

                System.out.println("The percentage is = " + percentage + " %");
            }
        }








//import java.util.Scanner;
//public class Percentage {
    //public static void main(String args[]){
        //float percentage;
        //foat total_marks;
        //float scored;
      //  Scanner sc = new Scanner(System.in);
    //    System.out.println("Enter your marks ::");
  //      scored = sc.nextFloat();
//
    //    System.out.println("Enter total marks ::");
  //      total_marks = sc.nextFloat();
//
    //    percentage = (float)((scored / total_marks) * 100);
  //      System.out.println("Percentage ::"+ percentage);
  //  }
//}

Comments

Popular posts from this blog

java chapter11 practice question on abstruct class and interfaces

DAY 12 -AZURE DP900(Microsoft Azure Data Fundamentals: Explore non-relational data in Azure)

java exercise4