Answered step by step
Verified Expert Solution
Link Copied!

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.
1. Start NetBeans.
2. 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.
3. 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 2 of 7
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 YourlastnameAssign1
(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 csci1010
(q) Click Finish
(r) A text editor window should pop up with the following source code (except
with your name instead of mine):
4. Modify the source code in the text editor to add CSCI 1010 Assignment 1 to the
comment in the line before the @author line.
5. Replace the line
// TODO code application logic here
with the line
System.out.println("Hello World!");
6. Build and debug the program:
Page 3 of 7
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 YourlastnameAssign1 to be the main class in the pop-up 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:
--- exec-maven-plugin:3.0.0:exec (default-cli) @ Assign1---
Hello World!
-------------------------------------------------------------
-----------
BUILD SUCCESS
-------------------------------------------------------------
-----------
Total time: 0.765 s
Finished at: 2022-12-13T21:34:57-06:00
-------------------------------------------------------------
-----------
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.
7. 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 name)s 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 4 of 7
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

ISBN: 0805302441, 978-0805302448

More Books

Students also viewed these Databases questions