Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started