Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC 120 Programming Project #2 Getting Started Create a project called proj2 (all lowercase, no spaces). If Eclipse has been giving you a module by

CSC 120 Programming Project #2 image text in transcribed
image text in transcribed
image text in transcribed
Getting Started Create a project called proj2 (all lowercase, no spaces). If Eclipse has been giving you a module by default, from the project creation dialog click Next and then de-selected the module option. Within this project create a class called Project2 (the project name should begin with a capital letter, everything else is lower case, no spaces). Be careful to create your project and class correctly. Use your lab1 handout as a reference. Remember to specify the package name as proj2 when you create the Project2 class. Open the Project2.java file on Blackboard and copy/paste it into the class you just created, deleting the code that was there initially. Review the statements in the file and run it to make sure you can enter input and it displays what you entered. You should copy/paste the String in the comment above the input statement as your input. You must use the indexOf and lastIndexOf methods that you explored in questions #3 and 5 of Planning Your Solution to receive full credit. Use the variables provided to store the various pieces of information you will extract from the full course information. Since you are working with a String and in some cases need an int (for the course id and course number) or double (for the number of credits) you will have to parse the String data to a number using either: Integer.parseInt() or Double.parseDouble() The syntax will be something like: variable - Integer.parseInt (variable.substring (spos, ePos)); The program should then create output in the following format. Course Id: 18169 Department: CSC Course Number: 120 Section: G1 Credits: 4.0 Course Name: Computer Science I If you do not get the correct output, go back and trace through your program to see where the problem(s) are and then fix them. Continue testing until you have the proper output. Just because the program works on I example of course data does not mean it will work on others. Use the String in the last comment of the program for additional testing - enter: 7531 MATH-1001-T11 4.25-Mathematical Reasoning Run the program. It should produce the following output: Course Id: 7531 Department: MATH Course Number: 1001 Section: T11 Credits: 4.25 Course Name: Mathematical Reasoning If you have different output that means your program was specific to the initial string and not general. It isn't accommodating the possibility that each part can be a different length. Trace through your program to see where it produces incorrect output and try to make your solution more general. Continue testing until you have the proper output for both strings. package proj2; import java.util.Scanner " .

Title:

Description:

* @author your name here public class Project 2 public static void main(Stringl] args) // should store the position of where a space is located int posofSpace; 1/ should start the position of where a vyphen is located int posofHyphen // should store the full course information as entered by the user String courseInfo // should store the various parts of the course information, do not change the data type of any of these variables String dept) String section: String course Int courseld; int courses double credits: Scanner sehr new Scanner(System.in) use 18169 CSC 120.61 4.0-Computer Science I as your initial input/ System.out.println("Please enter String with the course information"); courseIntosche.nextLine() System.out.println("The course Information is courseInfo) sche close 7531 MATH-1001-T12 4.25-Mathematical Reasoning For additional testing

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions