Case Study I
COMP 1010 Home > Java Fundamentals
IntroductionToday 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:
|
---|
{{{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
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.