Work on MP3

master
Chloe Fontenot 🏳️‍⚧️ 2022-10-16 19:44:21 +07:00
parent 9b131d5f88
commit 16d770b43c
9 changed files with 273 additions and 1 deletions

@ -0,0 +1,60 @@
/*
* 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 mp3_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class Calendar {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a year: ");
int year = input.nextInt();
System.out.print("Enter the first day of the year: ");
int firstDay = input.nextInt();
int startDay = firstDay;
int numberOfDaysInMonth = 0;
for (int month = 1; month <= 12; month++) {
System.out.print(" ");
switch (month) {
case 1: System.out.println("January " + year); numberOfDaysInMonth = 31; break;
case 2: System.out.println("February " + year);
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) numberOfDaysInMonth = 29;
else numberOfDaysInMonth = 28;
break;
case 3: System.out.println("March " + year); numberOfDaysInMonth = 31; break;
case 4: System.out.println("April " + year); numberOfDaysInMonth = 30; break;
case 5: System.out.println("May " + year); numberOfDaysInMonth = 31; break;
case 6: System.out.println("June " + year); numberOfDaysInMonth = 30; break;
case 7: System.out.println("July " + year); numberOfDaysInMonth = 31; break;
case 8: System.out.println("August " + year); numberOfDaysInMonth = 31; break;
case 9: System.out.println("September " + year); numberOfDaysInMonth = 30; break;
case 10: System.out.println("October " + year); numberOfDaysInMonth = 31; break;
case 11: System.out.println("November " + year); numberOfDaysInMonth = 30; break;
case 12: System.out.println("December " + year); numberOfDaysInMonth = 31; break;
}
System.out.println("-----------------------------");
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
int i = 0;
for (i = 0; i < startDay; i++) {
System.out.print(" ");
}
for (i = 1; i <= numberOfDaysInMonth; i++)
if (i < 10) System.out.print(" " + 1);
else System.out.print(" " + 1);
if ((i + startDay) % 7 == 0) {
System.out.println();
}
System.out.println();
System.out.println();
startDay = (startDay + numberOfDaysInMonth) % 7;
}
}
}

@ -4,10 +4,43 @@
*/
package mp3_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class FindTwoHighestScores {
public static void main(String[] args) {
// Create scanner
Scanner input = new Scanner(System.in);
// Define variables
double highScore1 = 0, highScore2 = 0, score;
String bestStudent1 = "", bestStudent2 = "", student;
int numberToIterate = 0;
// Compute
System.out.print("Enter the number of students: ");
numberToIterate = input.nextInt();
for (int i = 0; i != numberToIterate; i++) {
System.out.print("Enter a student name: ");
student = input.next();
System.out.print("Enter " + student + "'s score: ");
score = input.nextDouble();
if (score > highScore1) { // New high score detected
if (highScore1 != 0) {
highScore2 = highScore1; // assign highScore1 to highScore2
bestStudent2 = bestStudent1;
}
highScore1 = score; // assign current score to high score
bestStudent1 = student;
}
}
System.out.println("Best score belongs to " + bestStudent1 + ", with a score of " + highScore1);
System.out.println("Next best score belongs to " + bestStudent2 + ", with a score of " + highScore2);
}
}

@ -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 mp3_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class FindTwoHighestScoresDoWhile {
public static void main(String[] args) {
// Create scanner
Scanner input = new Scanner(System.in);
// Define variables
double highScore1 = 0, highScore2 = 0, score;
String bestStudent1 = "", bestStudent2 = "", student;
int numberToIterate = 0;
// Compute
System.out.print("Enter the number of students: ");
numberToIterate = input.nextInt();
int i = 0;
do {
System.out.print("Enter a student name: ");
student = input.next();
System.out.print("Enter " + student + "'s score: ");
score = input.nextDouble();
if (score > highScore1) { // New high score detected
if (highScore1 != 0) {
highScore2 = highScore1; // assign highScore1 to highScore2
bestStudent2 = bestStudent1;
}
highScore1 = score; // assign current score to high score
bestStudent1 = student;
}
i++;
} while (i != numberToIterate);
System.out.println("Best score belongs to " + bestStudent1 + ", with a score of " + highScore1);
System.out.println("Next best score belongs to " + bestStudent2 + ", with a score of " + highScore2);
}
}

@ -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 mp3_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class FindTwoHighestScoresWhile {
public static void main(String[] args) {
// Create scanner
Scanner input = new Scanner(System.in);
// Define variables
double highScore1 = 0, highScore2 = 0, score;
String bestStudent1 = "", bestStudent2 = "", student;
int numberToIterate = 0;
// Compute
System.out.print("Enter the number of students: ");
numberToIterate = input.nextInt();
int i = 0;
while (i != numberToIterate) {
System.out.print("Enter a student name: ");
student = input.next();
System.out.print("Enter " + student + "'s score: ");
score = input.nextDouble();
if (score > highScore1) { // New high score detected
if (highScore1 != 0) {
highScore2 = highScore1; // assign highScore1 to highScore2
bestStudent2 = bestStudent1;
}
highScore1 = score; // assign current score to high score
bestStudent1 = student;
}
i++;
}
System.out.println("Best score belongs to " + bestStudent1 + ", with a score of " + highScore1);
System.out.println("Next best score belongs to " + bestStudent2 + ", with a score of " + highScore2);
}
}

@ -0,0 +1,25 @@
/*
* 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 mp3_calebfontenot;
/**
*
* @author caleb
*/
public class GCD {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter the first number: ");
int n1 = input.nextInt();
System.out.print("Enter the second number: ");
int n2 = input.nextInt();
int d = (n1 < n2) ? n1 : n2;
for (; d >= 1; d--)
if ((n1 % d == 0) && (n2 % d == 0))
break;
System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
}
}

@ -0,0 +1,29 @@
/*
* 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 mp3_calebfontenot;
/**
*
* @author caleb
*/
public class GCDDoWhile {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter the first number: ");
int n1 = input.nextInt();
System.out.print("Enter the second number: ");
int n2 = input.nextInt();
int d = (n1 < n2) ? n1 : n2;
do {
if ((n1 % d == 0) && (n2 % d == 0)) {
break;
}
d--;
} while (d >= 1);
System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
}
}

@ -0,0 +1,29 @@
/*
* 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 mp3_calebfontenot;
/**
*
* @author caleb
*/
public class GCDWhile {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter the first number: ");
int n1 = input.nextInt();
System.out.print("Enter the second number: ");
int n2 = input.nextInt();
int d = (n1 < n2) ? n1 : n2;
while (d >= 1) {
if ((n1 % d == 0) && (n2 % d == 0)) {
break;
}
d--;
}
System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
}
}