Reshma K.

asked • 09/16/23

Trying to find error: cannot find symbol

Write a program that reads integers userNum and divNum as input, and outputs userNum divided by divNum three times. Note: End with a newline.

Ex: If the input is:

2000 2

the output is:

1000 500 250

Note: In Java, integer division discards fractions. Ex: 6 / 4 is 1 (the 0.5 is discarded).


import java.util.Scanner;


public class LabProgram {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int dividend = userNum;

int divNum;


for( int i=0; i<3; i++){

dividend = userNum / divNum;

System.out.print(dividend + " ");

}

}

}

LabProgram.java:6: error: cannot find symbol int dividend = userNum; ^ symbol: variable userNum location: class LabProgram LabProgram.java:10: error: cannot find symbol dividend = userNum / divNum; ^ symbol: variable userNum location: class LabProgram 2 errors

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.