Skip to content

Instantly share code, notes, and snippets.

@carbonrobot
Created July 29, 2015 13:19
Show Gist options
  • Save carbonrobot/74d186245714d29c41bb to your computer and use it in GitHub Desktop.
Save carbonrobot/74d186245714d29c41bb to your computer and use it in GitHub Desktop.
Sandbox/Java/Computer Console App
package com.company;
public class Computer
{
public Computer(){
}
private String graphicsCard;
public String getGraphicsCard(){
return this.graphicsCard;
}
public void setGraphicsCard(String gc){
this.graphicsCard = gc;
}
private int ram;
public int getRam(){
return this.ram;
}
public void setRam(int value){
this.ram = value;
}
public void setRam(String value){
this.ram = Integer.parseInt(value);
}
}
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// current shixnit
Computer current = new Computer();
System.out.println("Yo! Graphics me current");
current.setGraphicsCard(input.nextLine());
System.out.println("Yo! Ram me current");
current.setRam(input.nextLine());
// future shiz
Computer future = new Computer();
System.out.println("Yo! Graphics me future");
future.setGraphicsCard(input.nextLine());
System.out.println("Yo! Ram me future");
future.setRam(input.nextLine());
// calculate the qty of upgrade
// future ram / current ram * 100 = pct of upgrade
double pctOfUpgradeRam = (future.getRam() / current.getRam()) * 100;
// display the information including calculations
// Current Ram: 32GB, Future Ram: 64GB, 200% Upgrade
System.out.println("Current Ram: " + current.getRam() + "GB, Future Ram: " + future.getRam() + "GB, " + pctOfUpgradeRam + "% Upgrade");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment