MP2 Progress
This commit is contained in:
parent
1c473a521a
commit
fd4d12befa
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
/lab6_CalebFontenot/target/
|
||||
/03_Sep13_2022/target/
|
||||
/lab7_CalebFontenot/target/
|
||||
/MP2_CalebFontenot/target/
|
||||
|
14
MP2_CalebFontenot/pom.xml
Normal file
14
MP2_CalebFontenot/pom.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.calebfontenot.mp2_calebfontenot</groupId>
|
||||
<artifactId>MP2_CalebFontenot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>18</maven.compiler.source>
|
||||
<maven.compiler.target>18</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.mp2_calebfontenot.MP2_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.mp2_calebfontenot;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class CheckIBSN_10 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
// define vars
|
||||
int digit1, digit2, digit3, digit4, digit5, digit6, digit7, digit8, digit9, inputISBN, outputISBN;
|
||||
boolean debug = false;
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
// Divide the number up into 9 digits
|
||||
digit1 = inputISBN / 100000000 % 10;
|
||||
digit2 = inputISBN / 10000000 % 10;
|
||||
digit3 = inputISBN / 1000000 % 10;
|
||||
digit4 = inputISBN / 100000 % 10;
|
||||
digit5 = inputISBN / 10000 % 10;
|
||||
digit6 = inputISBN / 1000 % 10;
|
||||
digit7 = inputISBN / 100 % 10;
|
||||
digit8 = inputISBN / 10 % 10;
|
||||
digit9 = inputISBN / 1 % 10;
|
||||
//System.out.println(digit1 +"" + digit2 +"" + digit3 +"" + digit4 +"" + digit5 +"" + digit1 +"" + );
|
||||
//Print digits for debugging
|
||||
if (debug == true)
|
||||
{
|
||||
System.out.println("inputISBN: " + inputISBN);
|
||||
System.out.println("ISBN split into 9 digits: " + (digit1) + " " + (digit2) + " " + (digit3) + " " + (digit4) + " " + (digit5) + " " + (digit6) + " " + (digit7) + " " + (digit8) + " " + (digit9));
|
||||
}
|
||||
// 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");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("The ISBN-10 number is " + inputISBN + outputISBN);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.mp2_calebfontenot;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class RandomNumber {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Define vars
|
||||
int number = (int) (Math.random() * 12) + 1;
|
||||
System.out.println("Random generated number is " + number);
|
||||
|
||||
//long if else chain
|
||||
if (number == 1)
|
||||
System.out.println("Month is January");
|
||||
else if (number == 2)
|
||||
System.out.println("Month is February");
|
||||
else if (number == 3)
|
||||
System.out.println("Month is March");
|
||||
else if (number == 4)
|
||||
System.out.println("Month is April");
|
||||
else if (number == 5)
|
||||
System.out.println("Month is June");
|
||||
else if (number == 7)
|
||||
System.out.println("Month is July");
|
||||
else if (number == 8)
|
||||
System.out.println("Month is August");
|
||||
else if (number == 9)
|
||||
System.out.println("Month is September");
|
||||
else if (number == 10)
|
||||
System.out.println("Month is October");
|
||||
else if (number == 11)
|
||||
System.out.println("Month is November");
|
||||
else if (number == 12)
|
||||
System.out.println("Month is December");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user