Notes
![]() ![]() Notes - notes.io |
import java.util.ArrayList;
import java.util.Scanner;
public class BBCalc {
public static final int DAILY = 0;
public static final int LAB = 1;
public static final int MAJOR = 2;
public static final int DAILY_BUCK = 5;
public static final int LAB_BUCK = 3;
public static final int MAJOR_BUCK = 1;
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.print("How many banana bucks? ");
int numBucks = scan.nextInt();
System.out.println();
System.out.print("Current Daily Points: ");
int currentDaily = scan.nextInt();
System.out.println();
System.out.print("Current Lab Points: ");
int currentLab = scan.nextInt();
System.out.println();
System.out.print("Current Major Points: ");
int currentMajor = scan.nextInt();
System.out.println();
System.out.print("Total Daily Points: ");
int totalDaily = scan.nextInt();
System.out.println();
System.out.print("Total Lab Points: ");
int totalLab = scan.nextInt();
System.out.println();
System.out.print("Total Major Points: ");
int totalMajor = scan.nextInt();
System.out.println();
scan.close();
ArrayList<Integer> buckArray = createArray(numBucks);
ArrayList<Integer> optimalArray = new ArrayList<Integer>();
double biggestGrade = calcGrade(currentDaily, currentLab, currentMajor, totalDaily,
totalLab, totalMajor);
double newGrade;
while (buckArray.get(0) != 3)
{
int numDaily = 0;
int numLab = 0;
int numMajor = 0;
for (int i = 0; i < buckArray.size(); i++)
{
if (buckArray.get(i) == 0)
numDaily++;
if (buckArray.get(i) == 1)
numLab++;
if (buckArray.get(i) == 2)
numMajor++;
}
newGrade = calcGrade((currentDaily + (numDaily * DAILY_BUCK)),
(currentLab + (numLab * LAB_BUCK)), (currentMajor + (numMajor * MAJOR_BUCK)),
totalDaily, totalLab, totalMajor);
System.out.println(buckArray);
System.out.printf("%.4f", newGrade);
if (newGrade > biggestGrade)
{
biggestGrade = newGrade;
optimalArray = buckArray;
}
buckArray = updateArray(buckArray, buckArray.size() - 1);
}
System.out.printf("Highest Grade Possible: %.4f", biggestGrade);
System.out.println();
System.out.print("Optimal Distribution: ");
System.out.print(optimalArray);
}
static ArrayList<Integer> createArray(int num)
{
ArrayList<Integer> array = new ArrayList<Integer>();
for (int i = 0; i < num; i++)
{
array.add(DAILY);
}
return array;
}
static ArrayList<Integer> updateArray(ArrayList<Integer> array, int marker)
{
if (array.get(marker) == MAJOR)
{
if (marker == 0)
{
array.set(marker, MAJOR + 1);
return array;
}
else
{
array.set(marker, DAILY);
updateArray(array, marker - 1);
}
}
else
array.set(marker, array.get(marker) + 1);
return array;
}
static double calcGrade(int currentDaily, int currentLab, int currentMajor, int totalDaily,
int totalLab, int totalMajor)
{
double gradeSum = (double) currentDaily / totalDaily + (double) currentLab / totalLab +
(double) 2 * currentMajor / totalMajor;
double finalGrade = gradeSum / 4;
return finalGrade;
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team