r/learnjava • • Sep 24 '18

New to java need help correcting mistake

I turned in this assignment and I was missing some information. Below is the assignment and below that I will copy and past the source code I turned in. I received a 60 on the assignment. In this week's assignment I will have to build from this assignment and I wanted to know what I was missing in order to know how to correct the problem and build going forward. Write a java program named ShipmentDisplayYourName and post the .java source file and a screen shot of your program's execution results in a Word document in its dropbox. Do not use .zip or .txt or .png etc only .java and/or .docx.

Using a Scanner object read and display using a System.out.println object the following data items/fields for a Shipment:

Shipment ID: String shipId

Shipment weight: int shipWeight

Shipment volume: int shipVolume

Shipment origin station: String shipOrigin example MEM for Memphis

Shipment destination station: String shipDestination example SEA for Seattle

Calculate and display the cost (as a type double) of this shipment which is shipWeight times 10 plus shipVolume times 1.5.

Also display the class name and date and time as a Date object on a separate line.

import java.util.Date;

import java.util.Scanner;

public class ShipDisplay {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

String shipId;

String shipOriginMEM;

String shipDestinationSEA;

System.out.println("Shipment ID:");

int shipWeight = 1, shipVolume = 1;

double shipCost;

System.out.println("shipWeight10+shipVolume1.5");

System.out.println("MIS 2845");

Date thisDate = new Date();

SimpleDateFormat dateForm = new SimpleDateFormat("MM/dd/Y hh:mm a");

System.out.println(dateForm.format(thisDate));

}

}

1 Upvotes

3 comments sorted by

7

u/dusty-trash Sep 24 '18

Did you run your program before turning it in?

You don't print the shipweight pr ship volumn.. you print out the literal "shipWeight10+shipVolume1.5".

At my college you would have gotten a 0 for this. It's crazy the instructor gave you a 60, no offence.

Edit: You also don't take any input from the user..

6

u/[deleted] Sep 24 '18

I think watching a basic tutorial on java language would help you tremendously, and put at least a little effort into it.

5

u/[deleted] Sep 24 '18

Did you leave this assignment until the day of submission and then not even run it before handing it in? You're lucky you got any marks at all tbqh