master
Chloe Fontenot 🏳️‍⚧️ 2022-09-01 10:51:47 +07:00
parent 3099ec56e4
commit 2248cc8666
12 changed files with 182 additions and 7 deletions

1
.gitignore vendored

@ -1 +1,2 @@
/lab4_CalebFontenot/target/
/lab5_CalebFontenot/target/

@ -0,0 +1,17 @@
/*
* 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.lab4_calebfontenot;
/**
*
* @author caleb
*/
public class ABCD {
public static void main(String[] args)
{
int ABCD = 1234;
System.out.println(ABCD % 100);
}
}

@ -5,6 +5,8 @@
package com.calebfontenot.lab4_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
@ -12,13 +14,21 @@ package com.calebfontenot.lab4_calebfontenot;
public class Lab4_CalebFontenot {
public static void main(String[] args) {
int i = 11,
j = 22;
double x = 11.11,
y = 22.22;
// Setup Scanner;
Scanner input = new Scanner(System.in);
System.out.println("\n" + i + " + " + j + " = " + (i + j));
System.out.println("\n" + x + " + " + y + " = " + (x + y));
System.out.println("Enter i, j, x, and y: ");
int i = input.nextInt();
int j = input.nextInt();
double x = input.nextDouble();
double y = input.nextDouble();
//int i = 11,
// j = 22;
//double x = 11.11,
// y = 22.22;
// Changed addition to division
System.out.println("\n" + i + " / " + j + " = " + (i / j));
System.out.println("\n" + x + " / " + y + " = " + (x / y));
}
}

@ -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.lab5_calebfontenot</groupId>
<artifactId>lab5_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.lab5_calebfontenot.Lab5_CalebFontenot</exec.mainClass>
</properties>
</project>

@ -0,0 +1,17 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
*/
package com.calebfontenot.lab5_calebfontenot;
/**
*
* @author caleb
*/
public class Lab5_CalebFontenot {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}

@ -0,0 +1,48 @@
/*
* 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.lab5_calebfontenot;
/**
*
* @author caleb
*/
public class Operators {
public static void main(String[] args)
{
int x = 8; int y = 15; double d = 2;
//1. Increment x by 2;
//add code here
x += 2;
//2. Increment y by 5 using the += operator
//add code here
y += 5;
//3. Increment d by 1 using the ++ operator
//add code here
d++;
//4. Modify the expression below to print z1 = 1.5 and not 0.0
double z1 = ((double) x /(double) y ) * d++;
System.out.println("z1: " + z1 );
//5. Modify the expresion below the print z2 = 2.5 and not 0.0
double z2 = ((double) x /(double) y ) * ++d;
System.out.println("z2: " + z2 );
/* 6. Declare a variable z3 of type double and modify the
right hand side of the expression you built in step 5 for the
expression to evaluate 2.0.
Assign the evaluation to varible z3
*/
double z3 = ((double) x /(double) y * --d);
//add code here
System.out.println("z3: "+ z3 );
System.out.println("x=" + x + " y=" + y + " d=" + d +
" z1="+ z1 + " z2=" +z2 + " z3=" +z3);
}
}

@ -0,0 +1,36 @@
/*
* 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.lab5_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class Swap {
public static void main(String[] args)
{
// Create scanner
Scanner input = new Scanner(System.in);
// Define vars
double base,
power,
output;
// Prompt for input
System.out.println("Enter the base to calculate: ");
base = input.nextDouble();
System.out.println("Enter the power to calculate: ");
power = input.nextDouble();
// Calculate
output = Math.pow(base, power);
// Print result
System.out.println(base+"^"+power+" = "+ output);
}
}

@ -0,0 +1,32 @@
/*
* 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.lab5_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class WhatsYourName {
public static void main(String[] args)
{
// Create Scanner
Scanner input = new Scanner(System.in);
// Declare vars
String firstName,
lastName;
// Prompt for input
System.out.print("What's your name? (Enter first and last) ");
firstName = input.next();
lastName = input.next();
// Print output
System.out.println(firstName + " " + lastName + " is a beautiful name!");
}
}