What is the output produced by the following Java code?
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Concepts Of Programming Languages
Java: An Introduction to Problem Solving and Programming (7th Edition)
Artificial Intelligence: A Modern Approach
Starting Out with C++: Early Objects (9th Edition)
C How to Program (8th Edition)
- Exercise 1 : Write a Java program that computes the sum of even numbers less than or equal to n where n is given by the user (without nesting the control statements). Exercise 2 : Write a Java application that computes the sum of even numbers and the product of odd numbers that are in the range [a, b] where a and b are given by the user (without nesting the control statements, to do so you have to use 2 separate loops).arrow_forward1. Please explain what kind of syntax errors or problems the following statements might have. 1=x; //1. int x=3.0; //2. char ch="a"; //3._ int a==1; /4. int if=3; //5. 2.. What is the value of each output statement? Please write your answers on the provided line. public class Evaluation { public static void main(String arg[]) { int x=10, i; for (i=0; i<3; i++) X=x-2; System.out.println(i); //6.. System.out.println(x); //7.. int h=0; do { h=h+3; } while (h<2); System.out.println(h); //8. int k=2; while (k <2 ) { k=k+3; } System.out.println(k); //9.. }arrow_forwardA bug collector collects bugs every day for 7 days. Write a program that keeps a running total of the number of bugs collected during the 7 days. The program should prompt the user to enter the number of bugs collected for each day. Finally, when the program is finished, the program should display the total number of bugs collected.using javaarrow_forward
- The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. // DebugFive3.java// Determines whether item number on order is valid// Over 999 invalid// Less than 111 Invalid// Valid and less than 500 - Automotive Department// Valid and 500 or higher Housewares Departmentimport java.util.Scanner;public class DebugFive3{public static void main (String args[]){int item;String output;final int LOW = 111;final int HIGH = 999;final int CUTOFF = 500;Scanner input = Scanner(System.in);System.out.println("Please enter item number");item = input.nextInt();if(item > LOW)output = "Item number too low";elseif(item <= HIGH)output = "Item number too high";elseif(item == CUTOFF)output = "Valid - in Automotive Department";elsearrow_forwardFind the output of the following code. int ++a = 100; System.out.println(++a); A. 101 B. Compile error as ++a is not valid identifier C. 100 D. None Tha question is from Javaarrow_forwardstart // Assume that this program works, but that it needs to be structured and modularized. A No Yes B? C E No Yes D? F G Yes Yes H? J? No No K F Garrow_forward
- GradeProblemUsingSwitch_FamilyName A professor converts numeric grades to letter grades in the following way: Grade Letter Grade 93 – 99 A 87 – 92 B 80 – 86 70 – 79 D 65 - 69 E Using switch, create a java program that reads a numeric grade and output the equivalent letter grade. There should be an error message if the grade entered is invalid. Depicted below are sample outputs when the program is executed (the items in bold characters are inputted by the user, while the items in bold italic characters are calculated and outputted by the program): Enter a grade: 97 Letter Grade: A Enter a grade: 79 Enter a grade: 102 Invalid Input. Letter Grade: Darrow_forwardHi I need help with this it is printing out YEAR instead of the answer // This program calculates your age in the year 2050.// Input: None.// Output: Your current age followed by your age in 2050. public class NewAge2{ public static void main(String args[]) { int currentAge = 32; int newAge; int currentYear = 2022; // Declare a constant named YEAR and initialize it to 2050 final int YEAR = 2050; // Edit this statement so that it uses the constant named YEAR. newAge = currentAge + ( YEAR - currentYear ); System.out.println( " My Current Age is " + currentAge); // Edit this output statement so that is uses the constant named YEAR. System.out.println(" I will be " + newAge + " in + YEAR "); System.exit(0); }}arrow_forwardEnter a number: 5 Enter b number: 4 The value of 5 raised to the power of 4 is 625 Enter a number: 2 Enter b number: -4 The number b cannot be negative, try again (3) Write a Java program that prompts the user to enter a sentence (phrase), then it counts how many vowels and consonants in the sentence (phrase). The sentence (phrase) should be typed in by the user in response to a prompt message. Your program must consider the following specifications: Use Letter as the name of your class. Type your name and student number above the class declaration using a block/paragraph comment. Use documentation, comments and code style. Use significant and appropriate identifiers. Use appropriate data type for the variables. Here is a sample run of the program: Enter a string: Programming is fun The number of vowels is 5 The number of consonants is 11arrow_forward
- import java.util.Scanner; /** * Question 2 - This program allows money to be input in one currency and then its converted to a second * currency. The user must input the amount of money and 2 currency codes which should be USD (for dollar), * GBP (pound) and EUR (Euro). If either of the currency codes are incorrect, the program should display an error message * and end. If the user types in two currency codes that are the same, they should be trapped in a loop until the codes are different. * The money should be converted to the other currancy and the value of the monies in both currencies should be displayed. * * Student Number: * * Student Name: * */public class ChangeCurrency { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double money = 0, convertedMoney = 0; String firstCurrency = "", secondCurrency = ""; //The following are the exchance rates so euroToDollar = 1.14 means 1 euro is equal to…arrow_forwardJava Programming Assignment: Sammer, a smart child, just learned about series and numbers. He wrote the numbers in sequence and went to have milk. Unfortunately, while going to the shop he had a small accident and the coins are mixed with the other lady coin (May also mixed negative numbers) Now that you have been given these mixed numbers, your task is to help the little one finds the first missing natural number by using the Java programming language. Sample Input: 1 265-88 6 7 Sample Output: 1arrow_forwardIn Java Find the value of x , y after the statements are executed:arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT