Computer Science, asked by Gauravphulwani, 11 months ago

Java programs
using scanner class

Write a program to accept three sides of a triangle as parameter and check whether it can form a triangle or not if it forms a triangle check whether it is an acute angle obtuse angle a right angled triangle

Write a program to accept marks obtained by a student in Computer Science and print the grade accordingly
Marks
Above 90. A

70 to 89. B

50 to 69. C

below 50. D​

Answers

Answered by Anonymous
4

For the first Program:

import java.util.*;

public class Triangle

{

public static void main(String args[])

{

Scanner in =new Scanner(System.in);

float a,b,c,d,e,f;

System.out.println("Enter the length of the sides of the triangle");

a=in.nextFloat();

b= in.nextFloat();

c=in.nextFloat();

System.out.println("Enter the measure of the angles");

d=in.nextFloat();

e=in.nextFloat();

f=in.nextFloat();

if(a+b>c && a+c>b && c+b>a)

{

System.out.println("Triangle is possible");

else

System.out.println("Triangle is not possible");

}

if(d>90 || e>90 ||f>90)

{

System.out.println("Its an obtuse-angled triangle");

elseif(d=90||e=90 || f=90)

{

System.out.println("Its a right-angled triangle");

}

else

System.out.println("Its an acute-angled triangle");

}

}

}

_________________________________________________________

For the second program:

import java.util.*;

public class Grade

{

public static void main(String args[])

{

Scanner in =new Scanner(System.in);

float m;

char "A","B","C","D";

System.out.println(" Enter the mark obtained by the student");

m =in.nextFloat();

if(m>=90)

{

System.out.println("The grade is =" + "A");

elseif(90> M>=70)

{

System.out.println("The grade is=" +"B");

}

elseif(70>M>=50)

{

System.out.println("The grade is =" +"C");

}

else

System.out.println("The grade is="+"D");

}

}

}

_________________________________________________________

Similar questions