Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Note: Some data input to this program and some program output depends on your name. If you do not use your name as required, points
Note: Some data input to this program and some program output depends on your name.
If you do not use your name as required, points will be deducted for this assignment.
It is recommended that you print the instructions, or have them accessible on another
device, as you work on NetBeans.
Start NetBeans.
Update the user name in the User.properties file so that it displays your name as the
authors name every time you create a new java file using any of the templates
available in Netbeans. To modify the user name, follow the following steps:
a In the Tools menu, select Templates.
b In the dialog box that comes up click the Settings button.
c A new file should open up titled User.properties
d Uncomment the last line, and replace all text followed by user with your first
name and last name. The file should look like the following for a user with first
name Mir and last name Hasan.
e In the File menu select Save. You can also click on the Save All icon to save
your files.
f Close the User.properties file by clicking the X on the tab.
Create a new project:
g In the File menu select New Project...
h A form should appear called Choose Project.
i Under Categories: make sure that Java with Maven is selected.
j Under Projects: make sure that Java Application is selected.
Page of
Dept. CSIT, APSU
k Click Next
l If you get an error at this point about additional modules, mark all of the check
boxes, click Download and Activate.., and follow the instructions to install the
missing modules.
m A new form should appear called Name and Location.
n For Project Name: type YourlastnameAssign
o For Project Location: click Browse... and select a location on your computer
where you want to store your lab assignments. Remember this location! You
will need it later when you upload your source file.
p For Group ID type csci
q Click Finish
r A text editor window should pop up with the following source code except
with your name instead of mine:
Modify the source code in the text editor to add CSCI Assignment to the
comment in the line before the @author line.
Replace the line
TODO code application logic here
with the line
System.out.printlnHello World!";
Build and debug the program:
Page of
Dept. CSIT, APSU
a From the Run menu, under menu item Set Project Configuration, select
Customize.
b In the dialog box that opens, select Run from the left panel, and click Browse
next the Main Class textbox.
c Choose YourlastnameAssign to be the main class in the popup window.
d Click Select Main Class to close the dialog box. Then choose OK to save changes.
e Now, compile and run your program by clicking on the green triangle icon.
f If you typed in the program correctly, after displaying a lot of messages about
downloading jar files, it should display something like the following in the
Output pane of the window:
execmavenplugin::exec defaultcli @ Assign
Hello World!
BUILD SUCCESS
Total time: s
Finished at: T:::
This pane is also known as the console.
g Delete the semicolon ; character in the line you added to the main function.
h Notice now that the line you modified has a red squiggly line under it This
means that there is an error in your program and it will not compile. If you
hover over the line with the error it should give you a message saying ;
expected.
i Add the semicolon back in and the line should go away.
j Save your source file.
Rewrite your program so it calculates the fuel needed and total fuel cost of a trip. The
program will perform the following tasks:
a Display Welcome to your names fuel cost calculator.
b Ask the user to enter name of a trip destination.
c Ask the user to enter the distance to that trip destination in miles and the fuel
efficiency of their car in mpg or miles per gallon
d Calculate the fuel required to get to destination and display it
Page of
Dept. CSIT, APSU
i Use the formula: Fuel amount Distance Fuel efficiency, where Fuel is
in gallons, Distance is in miles and Fuel efficiency is in miles per gallon.
ii Your program should follow Java convention for variable names
camelCase
e Ask the user to enter fuel price in dollars per gallon in their area.
f Compute trip cost to get to destination and display it
i Use the formula: Trip fuel cost Fuel amount x Fuel price, where trip fuel
cost is in dollar amount, fuel is in gallons, and fuel price is in dollars per
gallon.
ii You need to convert this mathematical formula to a Java statement. Be
sure to use the right operator symbols! And, as before, follow Java
convention for variables names camelCase
g Compute and display total
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