Computer Science, asked by Harshi666, 1 year ago

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

Attachments:

james895: i was thinking your question is incomplete
Harshi666: oh.. yes.. but who ever reads the question will understand that the program is menu driven
Harshi666: no it is not
Harshi666: and Nitish can u ans it??
james895: ok
Harshi666: Nitish r u there??
nitish8089: ya! specify language...
Harshi666: java
nitish8089: ok...

Answers

Answered by nitish8089
39

code...

// 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");


}


}


}

Attachments:

nitish8089: now become serious.
nitish8089: goodluck / goodnight be happy..
nitish8089: don't ask why you are happy today..
james895: ok
james895: good night
jack6779: good morning friends
jack6779: happy teachers day
nitish8089: Happy teachers day
Harshi666: Happy teachers day too
Answered by rajatghadwal
1

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

Similar questions