Using a switch case statement, write a program to enter the value of r1 and r2. Calculate and display the equivalent resistances accordingly.

Answers
// here is three input.
// first for r1 value may think 5
// second for r2 value think 7
// third for option you connected the register in series then enter 1 in parallel then enter 2.
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
// taking input the value of registance:
System.out.println("enter the resistance of first register");
double r1=sc.nextDouble();
System.out.println("enter the resistance of second register");
double r2=sc.nextDouble();
// give option to choose your register in series or parallel:
System.out.println("if your register are connected in series enter 1. \nif your register are connected in parallel enter 2. ");
int choose=sc.nextInt();
double R1=0.0;
switch(choose){
case 1:
R1=r1+r2;
System.out.println("equivalent resistance"+r1+"and"+r2+"register connected in series is"+R1);
break;
case 2:
R1=(r1*r2)/(r1+r2);
System.out.println("equivalent resistance of "+r1+" and "+r2+" registance register connected in parallel is"+R1);
break;
default:
System.out.println("sorry invalid input");
}
}
}





Answer:
Explanation:question-1 write a program using switch case in which the user is asked to enter the marks and gets the grade accordingly. The criteria of the grade is given below: Above 90. - 70-89.99, 60-69.99, 50-59.99, 40-49.99, Below 40. Grade A , Grade B , Grade C , Grade D , Grade E , Fail