Difference between revisions of "Case Study I"

From CompSciWiki
Jump to: navigation, search
Line 1: Line 1:
 
{{
 
{{
 
1010Topic
 
1010Topic
|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. She brings you to your new desk and tells you that they have your first assignment.
+
|Introduction=
 
<p>
 
<p>
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.
+
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 [http://courses.cs.umanitoba.ca/index.asp?sec=3394&too=30&eve=1&ppa=5178 COMP 1010 coding standards].  
 
</p>
 
</p>
The resources available to you are located on this wiki page. Read over the resources and make the following changes to the code:
+
<p>
 +
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.
 +
</p>
 +
You are to complete the following tasks on the code below:
 
<ul>
 
<ul>
<li>Fix the code so it compiles and runs</li>
+
<li>Apply the company coding standards</li>
<li>Comment the code to explain what is happing</li>
+
<li>Add whitespace to the code file making code section</li>
 +
<li>Add comments to explain sections of code</li>
 +
<li>Find the errors in the code to make it function properly</li>
 +
<li>Add code to output progress reports as the program executes</li>
 +
<li>Add code to output all the calculated results in a readable format</li>
 
</ul>
 
</ul>
  
|Overview=You will apply the knowledge you have acquired from the previous three chapters to repair and clean this code file.
+
|Overview=You will apply the knowledge you have acquired from the previous three chapters and the course coding standards to repair and clean this code file.
  
 
|Chapter_TOC=[[Java Fundamentals]]
 
|Chapter_TOC=[[Java Fundamentals]]
 
}}
 
}}
  
==ISBN Overview==
+
<br />
 +
<br />
 +
 
 +
=ISBN Overview=
 +
 
  
 +
=Code=
 +
<pre>
 +
import javax.swing.*;
 +
import java.util.Date;
  
==Code==
+
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);
 +
        }
 +
}
 +
</pre>
  
==Solution==
 
  
 +
=Solution=
 +
[[Case Study I - Solution]]
  
==Links To Other Case Studies==
+
=Links To Other Case Studies=
 
[[Case Study II: Day Two at Funky Books Inc.]]<br />
 
[[Case Study II: Day Two at Funky Books Inc.]]<br />
 
[[Case Study III: Day Three at Funky Books Inc.]]<br />
 
[[Case Study III: Day Three at Funky Books Inc.]]<br />

Revision as of 00:35, 28 November 2007

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
  • 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

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.