Case Study I

From CompSciWiki
Revision as of 01:02, 28 November 2007 by DavidW (Talk | contribs)

Jump to: navigation, search

COMP 1010 Home > Java Fundamentals


Introduction

Today is your first day working for Funky Books Incorporated. You have been hired on as a Junior Software Developer with there software development department. Your boss explains that you will be working with Java and assumes that you are familiar with Java code and the SDK. Being the exceptionally employee that you are, you already took the time to go over the company coding standards for Java. It turns out that all the coding standards are the same as the COMP 1010 coding standards.

You arrive at your new desk to have the The Quality Assurance team of Funky Books Inc. requested a program that allows a user to input the ISBN number of a book and validate the number. The code that was produced was such a mess that the employee was let go. Since you are the person to fill the newly available position, it only makes sense that you take over the project.

You are to complete the following tasks on the code below:

  • Apply the company coding standards
  • Optimize the code by removing unnecessary variables
  • Add whitespace to the code file making code section
  • Add comments to explain sections of code
  • Find the errors in the code to make it function properly
  • Add code to output progress reports as the program executes
  • Add code to output all the calculated results in a readable format

   

{{{Body}}}



ISBN Overview

Code

import javax.swing.*;
import java.util.Date;

public class MessyCode_ISBN{

    public static void main (String [] args) {
        String temp = JOptionPane.showInputDialog("");int isbn = temp;
        int digit1 = (isbn / 10);int total = digit1 * 9;isbn = isbn / 10;
        int digit2 = (isbn % 10);total = total + digit2 * 8;isbn = isbn / 10;
        int digit3 = (isbn % 10);total = total + digit3 * 7;isbn = isbn // 10;
        int digit4 = (isbn % 10) total = total + digit4 + 6;isbn = isbn / 10;
        int digit5 = (isbn % 10);total = total + digit5 * 5;isbn = isbn / 10;
        int digit6 = (isbn % 10);total = total + digit6 * 4;isbn = isbn / 10;
		int digit7 = (isbn % 10);total = total + digit7 * 3;isbn = isbn / 10;
		int digit8 = (isbn % 10);total = total + digit8 * 2;isbn = isbn / 10;
		int digit9 = (isbn * 10);total = total + digit9 - 1;isbn = isbn / 10;int checkDigit = total % 11;
        System.out.println ("\n\nThe 10-digit ISBN is: " + temp + checkDigit);
        }
}


Solution

Case Study I - Solution

Resources

The resources needed to solve this case study can be found through the following links.

Internal Links

Chapter 1: Getting Started
Chapter 2: What is Programming?
Chapter 3: Java Fundamentals

External Links

COMP 1010 coding standards
ISBN Check Digit , Queen's University


Links To Other Case Studies

Case Study II: Day Two at Funky Books Inc.
Case Study III: Day Three at Funky Books Inc.
Case Study IV: Day Four at Funky Books Inc.