Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added out/.DS_Store
Binary file not shown.
Binary file added out/production/.DS_Store
Binary file not shown.
Binary file added out/production/c4t-java/.DS_Store
Binary file not shown.
Binary file added out/production/c4t-java/com/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/com/.DS_Store
Binary file not shown.
Binary file added src/com/codefortomorrow/.DS_Store
Binary file not shown.
Binary file added src/com/codefortomorrow/beginner/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package parallelArrayGradedAssignmentAMunshi;

import java.util.Scanner;

public class ParallelArrayGradedAssignmentAMunshi
{

public static void main(String[] args)
{
Scanner reader = new Scanner (System.in);

// Case, death, and recovery numbers are those reported by John Hopkins University at 2:01 PM on Wednesday 4/22/2020
// Population is as reported by worldometers.info at 2:01 PM on 4/22/2020
// Death rate, recovery rate, and infection rate are calculated using above data.
// Alveera's Risk Letter Grade is self determined and is a fun educated guess not actual scientific fact

//Data
String countries[] = {"United States", "Spain", "Italy", "France", "Germany", "United Kingdom", "Turkey", "Iran", "China", "Russia"};
String capitals[] = {"Washington D.C.", "Spain", "Rome", "Paris", "Berlin", "London", "Ankara", "Tehran", "Beijing", "Moscow"};
int population[] = {331002651, 46754778, 60461826, 65273511, 83783942, 67886011, 84339067, 83992949, 1439323776, 145934462};
int numofcases[] = {826248, 208389, 183957, 159315, 149044, 134635, 95591, 85996, 83868, 57999};
int deaths[] = {45894, 21717, 25085, 20829, 5165, 18151, 2376, 5391, 4636, 513};
int recoveries[] = {76070, 85915, 54543, 39850, 99400, 676, 16477, 63113, 77861, 4420};
double deathrate[] = {Math.round(deaths[0]/(double)numofcases[0]*10000)/100.0, Math.round(deaths[1]/(double)numofcases[1]*10000)/100.0, Math.round(deaths[2]/(double)numofcases[2]*10000)/100.0, Math.round(deaths[3]/(double)numofcases[3]*10000)/100.0, Math.round(deaths[4]/(double)numofcases[4]*10000)/100.0, Math.round(deaths[5]/(double)numofcases[5]*10000)/100.0, Math.round(deaths[6]/(double)numofcases[6]*10000)/100.0, Math.round(deaths[7]/(double)numofcases[7]*10000)/100.0, Math.round(deaths[8]/(double)numofcases[8]*10000)/100.0, Math.round(deaths[9]/(double)numofcases[9]*10000)/100.0};
double recoveryrate[] = {Math.round(recoveries[0]/(double)numofcases[0]*10000)/100.0, Math.round(recoveries[1]/(double)numofcases[1]*10000)/100.0, Math.round(recoveries[2]/(double)numofcases[2]*10000)/100.0, Math.round(recoveries[3]/(double)numofcases[3]*10000)/100.0, Math.round(recoveries[4]/(double)numofcases[4]*10000)/100.0, Math.round(recoveries[5]/(double)numofcases[5]*10000)/100.0, Math.round(recoveries[6]/(double)numofcases[6]*10000)/100.0, Math.round(recoveries[7]/(double)numofcases[7]*10000)/100.0, Math.round(recoveries[8]/(double)numofcases[8]*10000)/100.0, Math.round(recoveries[9]/(double)numofcases[9]*10000)/100.0};
double infectionrate[] = {Math.round(numofcases[0]/(double)population[0]*10000)/100.0, Math.round(numofcases[1]/(double)population[1]*10000)/100.0, Math.round(numofcases[2]/(double)population[2]*10000)/100.0, Math.round(numofcases[3]/(double)population[3]*10000)/100.0, Math.round(numofcases[4]/(double)population[4]*10000)/100.0, Math.round(numofcases[5]/(double)population[5]*10000)/100.0, Math.round(numofcases[6]/(double)population[6]*10000)/100.0, Math.round(numofcases[7]/(double)population[7]*10000)/100.0, Math.round(numofcases[8]/(double)population[8]*10000)/100.0, Math.round(numofcases[9]/(double)population[9]*10000)/100.0};
char riskgrade[] = new char [10];

// Determining Risk Grade
for (int x = 0; x < countries.length; x++)
{
if (infectionrate[x] > 0.25 || deathrate[x] > 25)
{
riskgrade[x] = 'A';
}
else if (infectionrate[x] > 0.2 || deathrate[x] > 15)
{
riskgrade[x] = 'B';
}
else if (infectionrate[x] > 0.15 || deathrate[x] > 10)
{
riskgrade[x] = 'C';
}
else if (infectionrate[x] > 0.1 || deathrate[x] > 5)
{
riskgrade[x] = 'D';
}
else
{
riskgrade[x] = 'F';
}
}

// Printing out instructions
System.out.println("The following countries have been stored in our database:");
System.out.println("[United States, Spain, Italy, France, Germany, United Kingdom, Turkey, Iran, China, Russia]\n");
System.out.println("The following stats are available for selection:");
System.out.println("[Capital, Number of Cases, Population, Deaths, Recoveries, Death Rate, Recovery Rate, Infection Rate, Risk Grade]");
System.out.println("\t**Risk Grade is a rating of how dangerous the virus is in that country, A being most dangerous and F being least dangerous.\n");
System.out.println("Type \"quit\" to end the program.\n");

String country = "";
String stat = "";
int index = -1;

// Enter a country
while (!country.equalsIgnoreCase("quit"))
{
while (index == -1)
{
System.out.print("Which country’s stats would you like to research? ");
country = reader.nextLine();
// Break While
if (country.equalsIgnoreCase("quit"))
{
index = -2;
}
// Finds index
for (int x = 0; x < countries.length; x++)
{
if (countries[x].equalsIgnoreCase(country))
{
index = x;
}
}
// Invalid Response
if (index == -1)
{
System.out.println("This response was invalid; try again.");
}
}

// QUIT GAME
if (country.equalsIgnoreCase("quit"))
{
break;
}

// Instructions
System.out.print("Which stat would you like? ");
stat = reader.nextLine();
System.out.println();

// Bring stat
if (stat.equalsIgnoreCase("capital"))
{
System.out.println(countries[index] + "'s capital is " + capitals[index] + ".");
}
else if (stat.equalsIgnoreCase("number of cases"))
{
System.out.println(countries[index] + " has " + numofcases[index] + " cases of COVID-19.");
}
else if (stat.equalsIgnoreCase("population"))
{
System.out.println(countries[index] + " has a population of " + population[index] + " people.");
}
else if (stat.equalsIgnoreCase("deaths"))
{
System.out.println(countries[index] + " has " + deaths[index] + " coronavirus related deaths.");
}
else if (stat.equalsIgnoreCase("recoveries"))
{
System.out.println(countries[index] + " has " + recoveries[index] + " people who recovered from COVID-19.");
}
else if (stat.equalsIgnoreCase("death rate"))
{
System.out.println(countries[index] + " has a " + deathrate[index] + "% coronavirus death rate.");
}
else if (stat.equalsIgnoreCase("recovery rate"))
{
System.out.println(countries[index] + " has a " + recoveryrate[index] + "% coronavirus recovery rate.");
}
else if (stat.equalsIgnoreCase("infection rate"))
{
System.out.println(countries[index] + " has a " + infectionrate[index] + "% COVID-19 infection rate.");
}
else if (stat.equalsIgnoreCase("risk grade"))
{
System.out.println(countries[index] + " has a risk grade of " + riskgrade[index] + ".");
}
else
{
System.out.println("This response was invalid; try again.");
}

// Prepare for loop
index = -1;
System.out.println();
System.out.println();
}
reader.close();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package parallelArrayProgramAMunshi;

import java.util.Scanner;

public class ParallelArrayProgramAMunshi
{

public static void main (String[]args)
{

Scanner reader = new Scanner (System.in);

String title[] = {"Game of Thrones", "Breaking Bad", "The Walking Dead", "Supernatural", "FRIENDS", "Doctor Who", "Black Mirror", "The Simpsons", "The Big Bang Theory", "How I Met Your Mother"};
int seasons[] = {8, 5, 10, 15, 10, 12, 5, 31, 12, 9};
int episodes[] = {73, 62, 144, 319, 236, 156, 22, 676, 281, 208};
int wins[] = {313, 138, 69, 22, 71, 113, 23, 173, 67, 25};
int nominations[] = {505, 217, 195, 85, 211, 195, 75, 309, 236, 90};
double rating[] = {8.8, 9.0, 8.1, 8.5, 8.5, 7.7, 7.9, 7.2, 7.9, 8.2};
int start[] = {2011, 2008, 2010, 2005, 1994, 2005, 2011, 1989, 2007, 2005};
int end[] = {2019, 2013, 2020, 2020, 2004, 2020, 2020, 2020, 2019, 2014};

System.out.println("The following shows have been stored in the array:\n");
System.out.println("[Game of Thrones, Breaking Bad, The Walking Dead, Supernatural, FRIENDS, Doctor Who, Black Mirror, The Simpsons, The Big Bang Theory, How I Met Your Mother]");
System.out.println("The following stats are available for selection:\n");
System.out.println("[Seasons, Episodes, Wins, Nominations, Rating, Start Year, End Year]\n");
System.out.println("Type \"quit\" to end the program.\n");

String show = "";
String stat = "";
int index = 0;
while (!show.equalsIgnoreCase("quit"))
{
System.out.print("Which show’s stats would you like to research? ");
show = reader.nextLine();
if (show.equalsIgnoreCase("quit"))
{
break;
}
for (int x = 0; x < title.length; x++)
{
if (title[x].equalsIgnoreCase(show))
{
index = x;
}
}
System.out.print("Which stat would you like? ");
stat = reader.nextLine();
if (stat.equalsIgnoreCase("seasons"))
{
System.out.println(show + " has aired " + seasons[index] + " seasons.");
}
if (stat.equalsIgnoreCase("episodes"))
{
System.out.println(show + " has aired " + episodes[index] + " episodes.");
}
if (stat.equalsIgnoreCase("wins"))
{
System.out.println(show + " recieved " + wins[index] + " wins.");
}
if (stat.equalsIgnoreCase("nominations"))
{
System.out.println(show + " recieved " + nominations[index] + " nominations.");
}
if (stat.equalsIgnoreCase("rating"))
{
System.out.println(show + " has a rating of " + rating[index]);
}
if (stat.equalsIgnoreCase("start year"))
{
System.out.println(show + " started airing in " + start[index] + " seasons.");
}
if (stat.equalsIgnoreCase("end year"))
{
System.out.println(show + " last aired in " + end[index] + " seasons.");
}

System.out.println();
System.out.println();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package parallelArrayPrograms;

import java.util.Scanner;
public class ParallelArrayPrograms
{
public static void main(String[]args)
{
//1
int num[][] = new int [1][5];
String street[][] = new String [1][5];
String apt[][] = new String [1][5];
int zip[][] = new int [1][5];
initintArray(num, "number");
initstrArray(street, "street");
initstrArray(apt, "apartment");
initintArray(zip, "zipcode");
System.out.println();
for (int c = 0; c < num[0].length; c++)
{
if (apt[0][c].equals("-"))
System.out.println(num[0][c] + " " + street[0][c] + " " + zip[0][c]);
else
System.out.println(num[0][c] + " " + street[0][c] + " Apt " + apt[0][c] + " " + zip[0][c]);
}

//2
String fn[][] = new String [1][6];
String li[][] = new String [1][6];
int id[][] = new int [1][6];
int pe[][] = new int [1][6];
int pp[][] = new int [1][6];
double g[][] = new double [1][6];
initstrArray(fn, "first name");
initstrArray(li, "last initial");
initintArray(id, "student ID");
initintArray(pe, "points earned");
initintArray(pp, "points possible");
for (int c = 0; c < g[0].length; c++)
{
g[0][c] = (pe[0][c])/((double)(pp[0][c])) * 100;
}
System.out.println();
for (int c = 0; c < fn[0].length; c++)
{
System.out.println(fn[0][c] + " " + li[0][c] + " " + id[0][c] + " " + pe[0][c] + " " + pp[0][c] + " " + (int)g[0][c] + "%");
}

}
public static void initintArray (int[][] n, String message)
{
Scanner reader = new Scanner(System.in);
for (int x = 0; x < n[0].length; x++)
{
System.out.print("Please enter a " + message + " " + (x+1) + ": ");
n[0][x] = reader.nextInt();
}

}
public static void initstrArray (String[][] n, String message)
{
Scanner reader = new Scanner(System.in);
for (int x = 0; x < n[0].length; x++)
{
System.out.print("Please enter a " + message + " " + (x+1) + ": ");
n[0][x] = reader.nextLine();
}

}
}
Loading