Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package cse110;
- import java.util.Scanner;
- /**
- *
- * @author acer
- */
- public class class2 {
- public static void main(String[] args) {
- //prob12();
- //prob15();
- multiple_16();
- //grade(52);
- }
- public static void prob12(){
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter your name");
- String name=sc.nextLine();
- System.out.println("Enter a number");
- int x=sc.nextInt();
- for(int i=0;i<x;i++){
- System.out.println(name);
- }
- }
- public static void prob15(){
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter a number");
- int x=sc.nextInt();
- int no=1;
- int i=1;
- while(no<=x){
- System.out.println("no"+no);
- no=7*i;
- i++;
- }
- }
- public static void multiple_16() {
- int mult1=0;
- int mult2=0;
- int i=1;
- int sum1=0;
- int sum2=0;
- int sum=0;
- while(mult1<=(300-7)){
- i++;
- mult1=7*i;
- sum1+=mult1;
- System.out.println("mult1: "+mult1);
- }
- i=1;
- while(mult2<=(300-9)){
- i++;
- mult2=9*i;
- sum2+=mult2;
- System.out.println("mult2: "+mult2);
- }
- sum=sum1+sum2;
- System.out.println("Sum: "+sum);
- }
- public static void grade(int marks){
- double cgpa=0;
- String grade="";
- String comment="";
- if(marks>50){
- if(marks>=90){
- cgpa=4.0;
- grade="A+";
- comment="Excellent";
- }
- else if(marks<90 && marks>=85){
- cgpa=3.7;
- grade="A-";
- comment="Excellent";
- }
- else if(marks<85 && marks>=80){
- cgpa=3.3;
- grade="B+";
- comment="Excellent";
- }
- else if(marks>=75 && marks<80){
- cgpa=3.0;
- grade="B";
- comment="Good";
- }
- else if(marks<75 && marks>=70){
- cgpa=2.7;
- grade="B-";
- comment="Good";
- }
- else if(marks<70 && marks>=65){
- cgpa=2.3;
- grade="C+";
- comment="Good";
- }
- else if(marks<65 && marks>=60){
- cgpa=2.0;
- grade="C";
- comment="Fair";
- }
- else if(marks<60 && marks>=57){
- cgpa=1.7;
- grade="C-";
- comment="Fair";
- }
- else if(marks<57 && marks>=55){
- cgpa=1.3;
- grade="D+";
- comment="Fair";
- }
- else if(marks<55 && marks>=52){
- cgpa=1.3;
- grade="D";
- comment="poor";
- }
- else{
- cgpa=1.0;
- grade="D-";
- comment="poor";
- }
- }
- else{
- cgpa=0.0;
- grade="F";
- comment="Failure";
- }
- System.out.println("your grade is: "+grade+"\nCGPA: "+cgpa+"\nstudent category: "+comment);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement