Output of this in Java?
char c = 'B'; switch (c) { case 'A': c= 'K'; case 'B': c = 'E'; case 'C': c = 'Q'; case 'D': c = 'H'; default: c = 'M'; } System.out.println(c);
Output of this in Java? char c = 'B'; switch (c) { case 'A': c= 'K';...
Output of this in java? String season = ""; int n = 0; switch (season) { case "Spring": n = 16; break; case "Summer": n = 17; break; case "Fall": n = 18; break; case "Winter": n = 19; break; default: n = 20; break; } System.out.println(n);
Pick a switch statement from the reading. Put it into a main() Java program and make it work. Attach the .java file and copyAndPaste the output into the WriteSubmissionBox The switch Statement S1.51 Multiway if-else statements can become unwieldy when you must choose from among many possible courses of action. If the choice is based on the value of an integer or character expres- sion, the switch statement can make your code easier to read. The switch statement begins with...
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...
Spell it out! Use the following Java concepts to compile the program below: String myName = "Chuck"; int length = myName.length(); char firstChar = myName.charAt(0); char secondChar = myName.charAt(1); if (myName.equals("Tom")) { System.out.println ("Sorry, Tom!"); } Write a program that uses a METHOD to translate these individual characters: input output input output input output input output input output a 4 g 9 m /\\/\\ s $ y ‘/ b B h |-| n |\\| t...
In java - Question 5 (Which CASE? - 10 pts) – What is the output of the following code? CREATE x <-- 5 SWITCH (x) C ASE 1: PRINTLINE (“hello world”) BREAK CASE 2: PRINTLINE (“hELLO wORLD”) CASE 3: PRINT (“HELLO WORLD”) BREAK CASE 4: PRINTLINE(“Hello”) CASE 5: PRINT(“World”) BREAK DEFAULT: BREAK
What is the output of running class C? The three Java classes are in separate Java files in the same directory (or in the same package). class A { public AO { System.out.println("The default constructor of A"); } // end A constructor } // end class A class B extends A { public BCString s) { System.out.println(s); } // end B constructor } // end class B public class C { public static void main(String[] args) { B b =...
The following pseudo-code describes a menu-driven algorithm:loopask the user to input one of the characters a, b, c, d, e, q read in a character from the keyboardif the character is'a' output your name and your tutor's name (hard-coded) 'b' input 3 double numbers x, y, z and output the largestand the smallest of the three numbers'c' input 2 integer numbers m and n, and display all thenumbers between m and n (both inclusive) with five numbers per line (note...
programming simple processor Implement switch construct as specified by pseudocode(this is similar to Java switch construct) switch A case 3: B := 1 break case 5: B := 22 break case 8: C := 32 break default: C := 99 endswitch
should be in C language What is the output of the following segment of C code: void CapsLetter (char* x, charl); int main() { char* text; text="This is some sample text."; CapsLetter(text, 'e'); printf("%s", text); return 0; سی void Caps Letter (char* x, char 1) { int i=0; while (x[i]!='\0') { if (x[i]==1) x[i]=1-32; } 1. This is som sample text. 2. THIS IS SOME SAMPLE TEXT. 3. This is some sample text. 4. this is some sample text. What...
Find the error in the following java code and explain how to correct it (val is a variable of type int): switch (val) { case 1: System.out.println ("The number is 1"); case 2: System.out.println ("The number is 2"); default: System.out.println ("The number is not 1 or 2"); break;