Question

What is the value of GPA when grade is 'B' in the following code segment? int...

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:
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for so many questions, I have solved the first 10,

here is the output as a screenshot I ran in my Java : )

======================================================================

Question # 1

Question # 2

Question # 3

Question # 4

Question # 5

Question # 6

Question # 7

Question # 8

Question # 9

System.out.println("A");
if (a==b) System.out.println("B");

Question # 10

Please post the remaining question as a separate post and I will answer them immediately!

thanks !

Add a comment
Know the answer?
Add Answer to:
What is the value of GPA when grade is 'B' in the following code segment? int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • Java debugging in eclipse package edu.ilstu; import java.util.Scanner; /** * The following class has four independent...

    Java debugging in eclipse package edu.ilstu; import java.util.Scanner; /** * The following class has four independent debugging * problems. Solve one at a time, uncommenting the next * one only after the previous problem is working correctly. */ public class FindTheErrors { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); /* * Problem 1 Debugging * * This problem is to read in your first name, * last name, and current year and display them in *...

  • (a)How many times does the code snippet given below display "Hello"? int x = 1; while...

    (a)How many times does the code snippet given below display "Hello"? int x = 1; while (x != 15) {    System.out.println ("Hello");    x++; } (b)What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 5) {    sum = sum + i;    i++; } System.out.println("The value of sum is " + sum); Quie 2 What is the output of the following snipped code? public class Test {...

  • What is the value of  result after the following code executes?   int a = 60; int b...

    What is the value of  result after the following code executes?   int a = 60; int b = 15; int result = 20; if (a = b) result *= 3; 30 20 60 10 code will not execute The numeric data types in C++ can be broken into two general categories which are integers and floating-point numbers singles and doubles real and unreal numbers numbers and characters numbers and literals Which line in the following program will cause a compiler error?...

  • use java and write in text a. Rewrite the following code segment using if statements. Assume...

    use java and write in text a. Rewrite the following code segment using if statements. Assume that grade has been declared as of type char. char grade= 'B';; switch (grade) { case 'A': System.out.println("Excellent"); break case 'B': System.out.println("Good"); default: System.out.println("you can do better”); } - b. write Java code that inputs an integer and prints each of its digit followed by ** e.gif the integer is 1234 then it should print 1**2**3**4 e.g. if the integer is 85 then it...

  • this needs to be in Java 1) What displays from this code segment when n=6? for...

    this needs to be in Java 1) What displays from this code segment when n=6? for (int i = 0; i < n; i++) System.out.print (i + “ ”); System.out.println (); for (int j=n; j > 0; j--) System.out.print ( j + “ “); 2) What displays from this code segment when n=6? for (int i = 0; i < n; i++) System.out.print (i + “ ”); System.out.println (); for (int j=n; j > 0; j--) System.out.print ( j +...

  • 5) What is the value of the variable answer after the code segment below completes? int...

    5) What is the value of the variable answer after the code segment below completes? int a, b, c; answer, a 3*b: b 5 10: c (a a b*b) / (c*c) answer = A).5 B) 2 C) 2.5 D) 250 ENone of the Above 8) What is the output of the following segment of code? int a 7, b= 3, c = 6 if (a> b c) printf"A"); if (b > a - с) printf ("B"); else printf("C") if (atb...

  • Question 41 Which of the following is NOT a valid assignment statement? A. x = 55;...

    Question 41 Which of the following is NOT a valid assignment statement? A. x = 55; B. 55 = x; C. x += 3; D. x = 56 + y; Question 42 What is the result of 45 / 4? A. 11.25 B. 10 C. 12 D. 11 Question 43 What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0");...

  • JAVA 5) What is the output of the following code? int a = 70; boolean b...

    JAVA 5) What is the output of the following code? int a = 70; boolean b = false; if(a >= 70) { System.out.print(1); if(b==true) { System.out.print(2); } } else { System.out.print(3); if(b==false) { System.out.print(4); } } System.out.print(5); 6) What is the output of the code above using these initial values? int a = 43; boolean b = false; 7) The following method is SYNTACTICALLY correct (meaning it will compile). True or false? public boolean method() { int value = 5;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT