Fix minor oversight in CheckIBSN_10.java
This commit is contained in:
parent
e3c5ac0f46
commit
5815fa35f3
Binary file not shown.
@ -5,23 +5,27 @@
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST2 {color: #ffc66d; font-family: monospace; font-style: italic}
|
||||
.ST3 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.ST0 {color: #287bde}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/MP2_CalebFontenot/src/main/java/com/calebfontenot/mp2_calebfontenot/CheckIBSN_10.java</td></tr></table>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/NetBeansProjects/ADSV Java/MP2_CalebFontenot/src/main/java/com/calebfontenot/mp2_calebfontenot/CheckIBSN_10.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
|
||||
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.mp2_calebfontenot;
|
||||
|
||||
@ -29,19 +33,18 @@ table {color: #888888; background-color: #313335; font-family: monospace; font-w
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment"> * </span><span class="ST1">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> CheckIBSN_10 {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST2">main</span>(String[] args)
|
||||
{
|
||||
<span class="comment">// Create scanner</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST3">in</span>);
|
||||
<span class="comment">// define vars</span>
|
||||
<span class="literal">int</span> digit1, digit2, digit3, digit4, digit5, digit6, digit7, digit8, digit9, inputISBN, outputISBN;
|
||||
<span class="literal">boolean</span> debug = <span class="literal">false</span>;
|
||||
|
||||
<span class="literal">boolean</span> debug = <span class="literal">true</span>;
|
||||
<span class="comment">// Scan individual numbers</span>
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the first 9 digits of an ISBN as an integer: </span><span class="string">"</span>);
|
||||
System.<span class="ST3">out</span>.print(<span class="string">"</span><span class="string">Enter the first 9 digits of an ISBN as an integer: </span><span class="string">"</span>);
|
||||
inputISBN = input.nextInt(); <span class="comment">// Get the first 9 digits of the ISBN</span>
|
||||
|
||||
|
||||
@ -59,21 +62,20 @@ table {color: #888888; background-color: #313335; font-family: monospace; font-w
|
||||
<span class="comment">//Print digits for debugging</span>
|
||||
<span class="literal">if</span> (debug == <span class="literal">true</span>)
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">inputISBN: </span><span class="string">"</span> + inputISBN);
|
||||
System.out.println(<span class="string">"</span><span class="string">ISBN split into 9 digits: </span><span class="string">"</span> + (digit1) + <span class="string">"</span> <span class="string">"</span> + (digit2) + <span class="string">"</span> <span class="string">"</span> + (digit3) + <span class="string">"</span> <span class="string">"</span> + (digit4) + <span class="string">"</span> <span class="string">"</span> + (digit5) + <span class="string">"</span> <span class="string">"</span> + (digit6) + <span class="string">"</span> <span class="string">"</span> + (digit7) + <span class="string">"</span> <span class="string">"</span> + (digit8) + <span class="string">"</span> <span class="string">"</span> + (digit9));
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">inputISBN: </span><span class="string">"</span> + inputISBN);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">ISBN split into 9 digits: </span><span class="string">"</span> + (digit1) + <span class="string">"</span> <span class="string">"</span> + (digit2) + <span class="string">"</span> <span class="string">"</span> + (digit3) + <span class="string">"</span> <span class="string">"</span> + (digit4) + <span class="string">"</span> <span class="string">"</span> + (digit5) + <span class="string">"</span> <span class="string">"</span> + (digit6) + <span class="string">"</span> <span class="string">"</span> + (digit7) + <span class="string">"</span> <span class="string">"</span> + (digit8) + <span class="string">"</span> <span class="string">"</span> + (digit9));
|
||||
}
|
||||
<span class="comment">// Calculate!</span>
|
||||
outputISBN = ((digit1 * <span class="number">1</span>) + (digit2 * <span class="number">2</span>) + (digit3 * <span class="number">3</span>) + (digit4 * <span class="number">4</span>) + (digit5 * <span class="number">5</span>) + (digit6 * <span class="number">6</span>) + (digit7 * <span class="number">7</span>) + (digit8 * <span class="number">8</span>) + (digit9 * <span class="number">9</span>)) % <span class="number">11</span>;
|
||||
|
||||
|
||||
<span class="comment">//Output</span>
|
||||
<span class="literal">if</span> (outputISBN == <span class="number">10</span>)
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">The ISBN-10 number is </span><span class="string">"</span> + inputISBN + <span class="string">"</span><span class="string">X</span><span class="string">"</span>);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">The ISBN-10 number is </span><span class="string">"</span> + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + <span class="string">"</span><span class="string">X</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span>
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">The ISBN-10 number is </span><span class="string">"</span> + inputISBN + outputISBN);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">The ISBN-10 number is </span><span class="string">"</span> + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + outputISBN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,7 @@ public class CheckIBSN_10 {
|
||||
Scanner input = new Scanner(System.in);
|
||||
// define vars
|
||||
int digit1, digit2, digit3, digit4, digit5, digit6, digit7, digit8, digit9, inputISBN, outputISBN;
|
||||
boolean debug = false;
|
||||
|
||||
boolean debug = true;
|
||||
// Scan individual numbers
|
||||
System.out.print("Enter the first 9 digits of an ISBN as an integer: ");
|
||||
inputISBN = input.nextInt(); // Get the first 9 digits of the ISBN
|
||||
@ -44,15 +43,14 @@ public class CheckIBSN_10 {
|
||||
// Calculate!
|
||||
outputISBN = ((digit1 * 1) + (digit2 * 2) + (digit3 * 3) + (digit4 * 4) + (digit5 * 5) + (digit6 * 6) + (digit7 * 7) + (digit8 * 8) + (digit9 * 9)) % 11;
|
||||
|
||||
|
||||
//Output
|
||||
if (outputISBN == 10)
|
||||
{
|
||||
System.out.println("The ISBN-10 number is " + inputISBN + "X");
|
||||
System.out.println("The ISBN-10 number is " + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + "X");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("The ISBN-10 number is " + inputISBN + outputISBN);
|
||||
System.out.println("The ISBN-10 number is " + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + outputISBN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user