<Snipped quote by Host>
that is something spectre would say
That was just an honest statement.
<Snipped quote by Host>
that is something spectre would say
<Snipped quote by whizzball1>
That was just an honest statement.
hey guys
so I wrote the first chapter of a short story involving Spectre, Ruby, Maddie, and Shinji
please feedback
drive.google.com/file/d/0B1nudriDMxTu…
I'm retelling Spectre's first appearance.
It's finally done. About as well as I can do it. Just over 200 lines of code I think. I'm gonna go in and add notes now so it is easier to follow.
Edit: If you bums stayed up super late like, ever, you would have seen me accidentally post my last name. Oh well, ya (literally) snooze, ya lose.public class Converter {
public double centTot;
private double totFees;
public Converter() {
}
double collectedFees = 0;
public void addQuarters(int quarters)
{
centTot = centTot + 25*quarters;
}
public void addDimes(int dimes)
{
centTot = centTot + 10*dimes;
}
public void addNickels(int nickels)
{
centTot = centTot + 5*nickels;
}
public void addPennies(int pennies)
{
centTot = centTot + 1*pennies;
}
public double getCollectedFees()
{
double tranFee = .078 * centTot;
return collectedFees = (tranFee + collectedFees) / 10;
}
public String getVoucher()
{
double tranFee = .078 * centTot;
double retVal = centTot - tranFee;
int twentyBill = 0;
int tenBill = 0;
int fiveBill = 0;
int oneBill = 0;
int returnQuarters = 0;
int returnDimes = 0;
int returnNickels = 0;
int returnPennies = 0;
while(retVal >= 2000)
{
twentyBill++;
retVal = retVal - 2000;
}
while(retVal >= 1000)
{
tenBill++;
retVal = retVal - 1000;
}
while(retVal >= 500)
{
fiveBill++;
retVal = retVal - 500;
}
while(retVal >= 100)
{
oneBill++;
retVal = retVal - 100;
}
while(retVal >= 25)
{
returnQuarters++;
retVal = retVal - 25;
}
while(retVal >= 10)
{
returnDimes++;
retVal = retVal - 10;
}
while(retVal >= 05)
{
returnNickels++;
retVal = retVal - 05;
}
while(retVal >= 01)
{
returnPennies++;
retVal = retVal - 01;
}
String a = "";
String b = "";
String c = "";
String d = "";
String e = "";
String f = "";
String g = "";
String h = "";
if(twentyBill != 0)
{
a = twentyBill + " twenties, ";
}
if(tenBill != 0)
{
b = tenBill + " tens, ";
}
if(fiveBill != 0)
{
c = fiveBill + " fives, ";
}
if(oneBill != 0)
{
d = oneBill + " ones, ";
}
if(returnQuarters != 0)
{
e = returnQuarters + " quarters, ";
}
if(returnDimes != 0)
{
f = returnDimes + " dimes, ";
}
if(returnNickels != 0)
{
g = returnNickels + " nickels, ";
}
if(returnPennies != 0)
{
h = returnPennies + " pennies, ";
}
String voucher = "You have receieved " + a + b + c + d + e + f + g + h;
centTot = 0;
System.out.println(voucher);
return voucher;
}
public double getCentTotal()
{
return centTot;
}
}import java.util.Scanner;
public class Kiosk {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
Converter dm = new Converter();
System.out.println("Welcome, Guest! Thank you for using Jacob *********'s Cash-for-Change Service!");
System.out.println();
String userInput = "y";
do
{
String input;
System.out.println("Our transaction has begun. Please deposit the change you wish to exchange.");
do
{
System.out.println(">");
input = in.nextLine();
input.toLowerCase();
if(input.equals("done"))
{
break;
}
else
{
String[] parts = input.split(" ");
if(parts.length !=2 || input.equals("done"))
{
System.err.println("Invalid Input. Please begin a new transaction.");
userInput = "n";
input = "done";
}
else
{
String part1 = parts[0];
String part2 = parts[1];
part2.toLowerCase();
int coinAmount = Integer.parseInt(part1);
if(part2.equals("quarter") || part2.equals("quarters"))
{
dm.addQuarters(coinAmount);
}
else if(part2.equals("dime") || part2.equals("dimes"))
{
dm.addDimes(coinAmount);
}
else if(part2.equals("nickel") || part2.equals("nickels"))
{
dm.addNickels(coinAmount);
}
else if(part2.equals("penny") || part2.equals("pennies"))
{
dm.addPennies(coinAmount);
}
else
{
System.err.println("Invalid input. Please try again.");
}
dm.getCollectedFees();
}
}
}while(input != "done");
dm.getVoucher();
System.out.println("The current transaction has ended. Would you like to make another? Please enter 'y' or 'n'.");
userInput = in.next();
while(!userInput.equals("y") && !userInput.equals("n"))
{
System.err.println("Invalid input. Please try again.");
userInput = in.next();
}
in.nextLine();
}while(userInput.equals("y"));
double moneyStolen = dm.getCollectedFees();
System.out.printf("Thank you for throwing money our way! Instead of going to a bank to get the same service for free, you have given us $%.2f. We appreciate your business!", moneyStolen);
<Snipped quote by Galaxy Raider>
Nice try Johnson. M
Also printf is gross.
<Snipped quote by Host>
I literally only used it to round the double to a realistic dollar value. Me no likey either.
<Snipped quote by whizzball1>
I absolutely love your idea of shinji in this. Its great. I honestly smiled the whole way through this, and even laughed at a few points.
<Snipped quote by Valiance>
Math.round()
Or (int)(myDouble) in order to cut off the value at the decimal.
Printf is difficult.
<Snipped quote by Host>
Hey at least he didn't write a separate program to find a single square root when there was already a function to do that in the language.
<Snipped quote by Valiance>
Math.round()
Or (int)(myDouble) in order to cut off the value at the decimal.
Printf is difficult.
<Snipped quote by Host>
It was the first thing I thought of because the professor recently made a point on how great printf is.
<Snipped quote by Valiance>
I have a knife you can borrow. Or would you rather take it through the legal system?
hey guys
so I wrote the first chapter of a short story involving Spectre, Ruby, Maddie, and Shinji
please feedback
drive.google.com/file/d/0B1nudriDMxTu…
I'm retelling Spectre's first appearance.
It's finally done. About as well as I can do it. Just over 200 lines of code I think. I'm gonna go in and add notes now so it is easier to follow.
Edit: If you bums stayed up super late like, ever, you would have seen me accidentally post my last name. Oh well, ya (literally) snooze, ya lose.public class Converter {
public double centTot;
private double totFees;
public Converter() {
}
double collectedFees = 0;
public void addQuarters(int quarters)
{
centTot = centTot + 25*quarters;
}
public void addDimes(int dimes)
{
centTot = centTot + 10*dimes;
}
public void addNickels(int nickels)
{
centTot = centTot + 5*nickels;
}
public void addPennies(int pennies)
{
centTot = centTot + 1*pennies;
}
public double getCollectedFees()
{
double tranFee = .078 * centTot;
return collectedFees = (tranFee + collectedFees) / 10;
}
public String getVoucher()
{
double tranFee = .078 * centTot;
double retVal = centTot - tranFee;
int twentyBill = 0;
int tenBill = 0;
int fiveBill = 0;
int oneBill = 0;
int returnQuarters = 0;
int returnDimes = 0;
int returnNickels = 0;
int returnPennies = 0;
while(retVal >= 2000)
{
twentyBill++;
retVal = retVal - 2000;
}
while(retVal >= 1000)
{
tenBill++;
retVal = retVal - 1000;
}
while(retVal >= 500)
{
fiveBill++;
retVal = retVal - 500;
}
while(retVal >= 100)
{
oneBill++;
retVal = retVal - 100;
}
while(retVal >= 25)
{
returnQuarters++;
retVal = retVal - 25;
}
while(retVal >= 10)
{
returnDimes++;
retVal = retVal - 10;
}
while(retVal >= 05)
{
returnNickels++;
retVal = retVal - 05;
}
while(retVal >= 01)
{
returnPennies++;
retVal = retVal - 01;
}
String a = "";
String b = "";
String c = "";
String d = "";
String e = "";
String f = "";
String g = "";
String h = "";
if(twentyBill != 0)
{
a = twentyBill + " twenties, ";
}
if(tenBill != 0)
{
b = tenBill + " tens, ";
}
if(fiveBill != 0)
{
c = fiveBill + " fives, ";
}
if(oneBill != 0)
{
d = oneBill + " ones, ";
}
if(returnQuarters != 0)
{
e = returnQuarters + " quarters, ";
}
if(returnDimes != 0)
{
f = returnDimes + " dimes, ";
}
if(returnNickels != 0)
{
g = returnNickels + " nickels, ";
}
if(returnPennies != 0)
{
h = returnPennies + " pennies, ";
}
String voucher = "You have receieved " + a + b + c + d + e + f + g + h;
centTot = 0;
System.out.println(voucher);
return voucher;
}
public double getCentTotal()
{
return centTot;
}
}import java.util.Scanner;
public class Kiosk {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
Converter dm = new Converter();
System.out.println("Welcome, Guest! Thank you for using Jacob *********'s Cash-for-Change Service!");
System.out.println();
String userInput = "y";
do
{
String input;
System.out.println("Our transaction has begun. Please deposit the change you wish to exchange.");
do
{
System.out.println(">");
input = in.nextLine();
input.toLowerCase();
if(input.equals("done"))
{
break;
}
else
{
String[] parts = input.split(" ");
if(parts.length !=2 || input.equals("done"))
{
System.err.println("Invalid Input. Please begin a new transaction.");
userInput = "n";
input = "done";
}
else
{
String part1 = parts[0];
String part2 = parts[1];
part2.toLowerCase();
int coinAmount = Integer.parseInt(part1);
if(part2.equals("quarter") || part2.equals("quarters"))
{
dm.addQuarters(coinAmount);
}
else if(part2.equals("dime") || part2.equals("dimes"))
{
dm.addDimes(coinAmount);
}
else if(part2.equals("nickel") || part2.equals("nickels"))
{
dm.addNickels(coinAmount);
}
else if(part2.equals("penny") || part2.equals("pennies"))
{
dm.addPennies(coinAmount);
}
else
{
System.err.println("Invalid input. Please try again.");
}
dm.getCollectedFees();
}
}
}while(input != "done");
dm.getVoucher();
System.out.println("The current transaction has ended. Would you like to make another? Please enter 'y' or 'n'.");
userInput = in.next();
while(!userInput.equals("y") && !userInput.equals("n"))
{
System.err.println("Invalid input. Please try again.");
userInput = in.next();
}
in.nextLine();
}while(userInput.equals("y"));
double moneyStolen = dm.getCollectedFees();
System.out.printf("Thank you for throwing money our way! Instead of going to a bank to get the same service for free, you have given us $%.2f. We appreciate your business!", moneyStolen);
<Snipped quote by whizzball1>
I've only barely skimmed it, but I'll try to read it properly this afternoon after my classes are done.
<Snipped quote by Host>
Come on now. It's not fun, but it's not that bad. It was one of the easier things in my entire 200 lines.
<Snipped quote by Galaxy Raider>
i am disappointed that you defined several empty strings by actually defining the empty strings