Concept explainers
Explanation of Solution
Given code:
//Define the main class
class Main
{
    //Define the main method
    public static void main(String[] args)
    {
        //Declare variables
        int product = 1;
        int max = 20;
        //Loop from 0 through 20
        for(int i = 0; i<= max; i++)
            //Calcula...
Explanation of Solution
Fixing the code:
The fixed part is highlighted
//Define the main class
class Main
{
    //Define the main method
    public static void main(String[] args)
    {
        //Declare variables
        int product = 1;
        int max = 20;
        //Loop from 0 through 20
        for(int i = 1; i<= max; i++)
            //Calculate product
            product = product * i;
        //Print the result
System...
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
- What is the output of the code segment below?  int me = 1; int you = me; int them; while (you - me < 10) { them = me + you; System.out.print(me + " "); me = you; you = them; } System.out.print(me);arrow_forwardAfter the code is executed, what is the value of variable “a”?arrow_forwardNeed help in visualizing with an example for the following statementarrow_forward
- What is the output from each of the following pseudocode statements?arrow_forwardFor each of the two programs below, suppose that you had the time and memory required to run the code to completion. What would the value of the variable grid be at the end of the program?arrow_forwardWhat are the memory sections for variables in the following code:Â Â Â Â Â Â Â Â Â Â int *x=new int; static int y; int z;arrow_forward
- This is a debugging problem that I am completely stuck on. This is the question - 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. This is the code - // DebugFive1 // Adds your lunch bill // Burger and hot dog are $2.59 // Grilled cheese and fish are $1.99 // Fries are 89 cents import java.util.*; public class DebugFive1 {    public static void main(String args[])    {       Scanner input = new Scanner(System.in);       final double HIGH_PRICE = 2.59;       final double MED_PRICE = 1.99;       final double LOW_PRICE = 0.89;       String usersChoiceString;       int usersChoice;       double bill;       System.out.println("Order please\n1 - Burger\n2 - Hotdog" +       "\n3 - Grilled cheese\n4 - Fish sandwich");       usersChoiceString = input.next();       usersChoice == Integer.parseInt(usersChoiceString);…arrow_forwardWhat would be the output of the following code?a= [1 0 2] ;      b = [3 0 7]   ;      c=a.*b;arrow_forwardWhat would be the output from this codearrow_forward
- If you run the following program, in which order the statements of this program will be executed? Your answer should be a sequence comma separated of line numbers without any extra spaces, e.g., 1,2,3,4,5,6,7,8 etc. What will this code print out?arrow_forwardWrite declarations to declare each variable to have the specified type and initial value: Problem: numberOfDeposits and numberOfChecks to be of type int, each with an initial value of 0; totalDeposits and totalChecks to be of type double, each with an initial value of 0.0; and serviceCharge to be of type double with an initial value of 0.25arrow_forwardWhat is the value of x after inputting the following statements? Â int x = 5; x += 3; x /= 2;arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education