Skip to content

Instantly share code, notes, and snippets.

@resir014
Last active August 29, 2015 13:57
Show Gist options
  • Save resir014/9780433 to your computer and use it in GitHub Desktop.
Save resir014/9780433 to your computer and use it in GitHub Desktop.
Some more random assignment thing.
/*
* Copyright (c) 2014 Resi Respati <resir014@gmail.com>
*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
*
*/
import java.util.*;
/**
* Some fucking storefront or other shit.
*/
public class WankingWallaby {
public static void main(String[] args) {
//Classy as fuck header.
int width = 80;
String msg0 = "Welcome to Bluejack Store";
String msg1 = "====================================";
int offset0 = (width / 2) + (msg0.length() / 2);
int offset1 = (width / 2) + (msg1.length() / 2);
System.out.printf("%" + offset0 + "s\n", msg0);
System.out.printf("%" + offset1 + "s\n\n", msg1);
//Think using consoles are easy? Heh, try the goddamn Linux terminal.
Scanner console = new Scanner(System.in);
//This shit lets you input a name so we can know who the fuck is using this.
System.out.print("Enter your name: ");
String n = console.nextLine();
//Alright, now welcome to the fucking storefront.
System.out.println("\nHai " + n + ",");
System.out.println("List Item [0 if you don't want to order] :");
//We don't accept Bitcoins, you fuck.
String curr = "Rp.";
//Here's the fucking price tag, bitches.
String[] itemList = {"CPU", "Monitor", "Keyboard", "Mouse", "Printer"};
double[] pTag = {2000000, 2400000, 200000, 150000, 850000};
System.out.printf("%-10s %-3s %,13.2f %2s", itemList[0], curr, pTag[0], ": ");
int qty0 = console.nextInt();
System.out.printf("%-10s %-3s %,13.2f %2s", itemList[1], curr, pTag[1], ": ");
int qty1 = console.nextInt();
System.out.printf("%-10s %-3s %,13.2f %2s", itemList[2], curr, pTag[2], ": ");
int qty2 = console.nextInt();
System.out.printf("%-10s %-3s %,13.2f %2s", itemList[3], curr, pTag[3], ": ");
int qty3 = console.nextInt();
System.out.printf("%-10s %-3s %,13.2f %2s", itemList[4], curr, pTag[4], ": ");
int qty4 = console.nextInt();
//Calculates total.
double t0 = pTag[0] * qty0;
double t1 = pTag[1] * qty1;
double t2 = pTag[2] * qty2;
double t3 = pTag[3] * qty3;
double t4 = pTag[4] * qty4;
double gTotal = t0+t1+t2+t3+t4;
//Now we're going to display how much money you wasted buying our shit.
System.out.println("\nPurchase List :");
System.out.printf("%-10s : %1d = %-3s %,13.2f\n", itemList[0], qty0, curr, t0);
System.out.printf("%-10s : %1d = %-3s %,13.2f\n", itemList[1], qty1, curr, t1);
System.out.printf("%-10s : %1d = %-3s %,13.2f\n", itemList[2], qty2, curr, t2);
System.out.printf("%-10s : %1d = %-3s %,13.2f\n", itemList[3], qty3, curr, t3);
System.out.printf("%-10s : %1d = %-3s %,13.2f\n", itemList[4], qty4, curr, t4);
//Again, we don't fucking accept Bitcoins.
System.out.printf("\n%-10s : %-3s %,13.2f\n", "Total", curr, gTotal);
System.out.println("\nThank you for shopping with us!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment