Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the value of GPA when grade is 'B' in the following code segment? int GPA=0; switch (grade) { case 'A': case 'a': GPA

What is the value of GPA when grade is 'B' in the following code segment? int GPA=0; switch (grade) { case 'A': case 'a': GPA = GPA + 1; case 'B': case 'b': GPA = GPA + 1; case 'C': case 'c': GPA = GPA + 1; case 'D': case 'd': GPA = GPA + 1; }
4
3
2
1
None of the above
#2. Branching - switch statements...

Extra info/hint? It's free

What is the value of GPA when grade is 'B' in the following code segment? int GPA=0; switch (grade) { case 'D': case 'd': GPA = GPA + 1; case 'C': case 'c': GPA = GPA + 1; case 'B': case 'b': GPA = GPA + 1; case 'A': case 'a': GPA = GPA + 1; }
4
3
2
1
None of the above
#3 Branching - switch statements...

Extra info/hint? It's free

What is the value of GPA when grade is 'd' in the following code segment? ** Note the numbers have been switched around in the statements** int GPA; switch (grade) { case 'A': case 'a': GPA = 5; break; case 'D': case 'd': GPA = 8; break; case 'C': case 'c': GPA = 7; break; case 'B': case 'b': GPA = 10; break; default: GPA = 2; }
2
5
7
8
None of the above
4. Branching - switch statements...

Extra info/hint? It's free

What is the value of GPA when grade is 'F' in the following code segment? int GPA=0; switch (grade) { case 'A': case 'a': GPA = GPA + 1; case 'B': case 'b': GPA = GPA + 1; case 'C': case 'c': GPA = GPA + 1; case 'D': case 'd': GPA = GPA + 1; }
4
3
2
1
None of the above
#5. Conditional if statement...
What will be in grade after the following code segment is executed? score = 70; if (score > 90) grade = 'A'; else if (score > 80) grade='B'; else if (score>70) grade='C'; else if (score>60) grade='D'; else grade = 'E'; 

#6 Conditional if statement...
What will be in grade after the following code segment is executed? score = 70; if (score > 60) grade = 'E'; else if (score > 70) grade='C'; else if (score>80) grade='B'; else if (score>90) grade='A'; else grade = 'D'; System.out.print(grade);

#7. Decision/Conditional / if statement...
What is the output of the following code segment? int a=1, b=2, c=3; if (a >= b) { c=a; a=b; b=c; } System.out.print(a+" "+b+" "+c);

#8. Decision / Conditional / if statement...
What is the output of the following code segment? int a=1, b=2, c=3; if (a >= b) { c=a; a=b; b=c; } else { b=a; a=c; c=b; } System.out.print(a+" "+b+" "+c);

#9. Decision / Conditional / if statement...
Given the following code segment: if (a > b || a < b) { System.out.println("A"); } else if ( a == b) { System.out.println("A"); System.out.println("B"); } else { System.out.println("A"); System.out.println("C"); } ============== Question: Which one(s) of the following code segments would yield the same output as the above code segment? Assume that both a and b are initialized as integers.
System.out.println("A"); if (a==b) System.out.println("B"); else System.out.println("C");
System.out.println("A"); if (a==b) System.out.println("B");
All of the above
None of the above
#10 Conditional if statement...
What will be printed for d by the following program segment? a=20; b=30; c=10; if (a>b && a>c) d=a; else if (b>a && b>c) d=b; else if (c>a && c > b) d=c; System.out.print(d);

#11. Program to read an integer and print if it is odd or even...
Write a program which reads an integer and prints ODD or EVEN depending on whether the integer it read is an odd or even number. For example, if the input is 3, output should be 3 is ODD
Sample console I/O execution sequence
Enter an integer and I'll tell you if it is odd or even: 3 3 is ODD
You may attach and submit your program:
#12. Read two distinct integers and print the maximum...
Write a program that reads two distinct integers and prints the maximum of the two integers. For example, if the input is 1 2, output should be 2.
Sample console I/O execution sequence
Enter two integers: 1 2 The maximum of 1 and 2 is: 2
You may attach and submit your program:
#13. Program to find maximum of integers...
Write a program that reads three distinct integers and prints the maximum of the three integers entered. For example, if the input is 3 1 2, output should be 3.
Sample console I/O execution sequence
Enter three distinct integers: 3 1 2 The maximum is: 3
You may attach and submit your program:
#13. Program to find median...
Write a program which reads 3 distinct integers and prints the middle (median) of the three numbers when the numbers are in order. For example, if the input is 3 1 2, output should be 2. Or if the input is 5 6 2, the output should be 5.
Sample console I/O execution sequence
Enter three integers and you will get the median: 3 1 2 The median is: 2
Enter three integers and you will get the median: 5 6 2 The median is: 5
You may attach and submit your program:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

How would you compute labour turnover under separation method? LO-7

Answered: 1 week ago

Question

Are your goals SMART?

Answered: 1 week ago