Question: open a new project in NetBeans ( File , New Project ) accept defaults ( Java ) project name: division this program will take two
open a new project in NetBeans File New Project
accept defaults Java
project name: division
this program will take two integers, divided one by the other, and display the result
enter the following command statements between the curly brackes under the main function:
output the following, by using the System.out.println; command
"this program will take two integers, divided one by the other, and display the result"
declare two numbers as integers and assign values
number
number
new data type: double
used for division
used when value is a decimal
declare a double called quotient
assign quotient the expression number number
click on Save All button if button disabled, saved automatically
run the program; your output should look like this:
divided by equals
BUILD SUCCESS
the answer is wrong; yet, it says build success; huh?
the reason: when two integers are divided, the computer assumes the answer must be an integer, also; so it drops any decimal
how to fix? make the integers double, too
change number and number from int to double
save; run; now output should say
divided by equals
BUILD SUCCESS
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
