The work I'm doing right now for java
For the first assignment [quote]Suppose you buy 100 shares of a stock at $12 per share, then another
100 at $10 per share, and then sell 150 shares at $15. You have to pay
taxes on the gain, but exactly what is the gain? In the United States,
the FIFO rule holds: You first sell all shares of the first batch for
a profit of $300, then 50 of the shares from the second batch, for a
profit of $250, yielding a total profit of $550. Write a program that
can make these calculations for arbitrary purchases and sales of
shares in a single company. The user enters commands buy quantity
price, sell quantity (which causes the gain to be displayed), and
quit. Keep a queue of objects of a class StockBlock that contains the
quantity and price of a block of shares. Do not break the block apart
into separate stocks. The example above should store 2 blocks, not
200. For the draft, your program should work for a single purchase
and sale. For both versions, you should use the Queue interface, and
you can assume integer prices. There will be no short-sale attempts.
(I will never try to sell more than I own.)[/quote]
[B]I have already written the draft and I got the it to buy one share, but now I have to buy 2 shares[/B]
How would I go with this?
[code]import java.util.LinkedList;
import java.util.Queue;
/**
* @author
* 7a
*/
/**
Class for simulating trading a single stock at varying prices.
*/
public class StockHolding {
private Queue<StockBlock> stocks;
private String name;
private StockBlock stk;
public StockHolding(String ticker)
{
name = ticker;
stocks = new LinkedList<StockBlock>();
}
/**
Handle a user buying a given quantity of stock at a given price.
*/
public void buy(int quantity, int price)
{
stk = new StockBlock(quantity,price);
stocks.add(stk);
}
/**
Handle a user selling a given quantity of stock at a given price.
@return the profit from the sale
*/
public int sell(int quantity, int price)
{
return quantity*price-quantity*(stk.pri);
}
private class StockBlock
{
private int qua;
private int pri;
public StockBlock (int a, int b)
{
qua = a;
pri = b;
}
}
}
[/code]
[code]/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author taylor
*/
public class Hw7aDraftTester {
public static void main(String[] args)
{
StockHolding s = new StockHolding("AAPL");
s.buy(100, 12);
System.out.println("Profit: " + s.sell(50, 15));
System.out.println("Expected: 150");
StockHolding s2 = new StockHolding("FFT");
s2.buy(3000, 20);
System.out.println("Profit: " + s2.sell(3000, 10));
System.out.println("Expected: -30000");
}
}
Hw7aFinalTester.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author taylor
*/
public class Hw7aFinalTester {
public static void main(String[] args)
{
StockHolding s = new StockHolding("AAPL");
s.buy(100, 12);
s.buy(100, 9);
System.out.println("Profit: " + s.sell(150, 15));
System.out.println("Expected: 600");
s.buy(200, 25);
System.out.println("Profit: " + s.sell(250, 20));
System.out.println("Expected: -450");
}
}[/code]
Draft and Final Tester!
How do i set a in game chat command so when people type !donate it opens their in game browser to a specified donation page? Please help, for TTT Gmod, with ULX admin mod
Wrong forum buddy, [URL="http://facepunch.com/forumdisplay.php?f=65"]Garry's mod Developer Discussion[/URL] is what you're looking for.
I have
[img]http://puu.sh/2si2F[/img]
Basically it is a custom class in a DLL that has runs commands and makes it its own element inside of a winform, inheriting Label.
Basically instead of it drawing right there on the winform in the editor view, I am wanting so in place of all the stuff rendering is just a simple image stating that that box is an item that I created. Or not having anything drawn inside that custom element box.
How do I do a MySQL statement that selects rows ending in 'st' or 'rd'?
[QUOTE=SammySung;40127987]How do I do a MySQL statement that selects rows ending in 'st' or 'rd'?[/QUOTE]
Does this have to be pure sql?
[QUOTE=SammySung;40127987]How do I do a MySQL statement that selects rows ending in 'st' or 'rd'?[/QUOTE]
SELECT * FROM herp WHERE derp LIKE '%st';
Like that?
[QUOTE=eternalflamez;40128497]Does this have to be pure sql?[/QUOTE]
It's alright, I figured it out. And I'm not really sure, it's part of my uni course.
[QUOTE=SammySung;40127987]How do I do a MySQL statement that selects rows ending in 'st' or 'rd'?[/QUOTE]
WHERE .. LIKE '%st' AND .. LIKE '%rd'
[editline]2nd April 2013[/editline]
[QUOTE=eternalflamez;40128497]Does this have to be pure sql?[/QUOTE]
MySQL isn't pure sql :v:
So I have query that looks like this
[code]
SELECT C.CITYNAME, W.CAPACITY
FROM CITY C
INNER JOIN WAREHOUSE W
ON C.CITYCODE = W.CITYCODE
WHERE W.CAPACITY >=10000[/code]
Which presents this: [img]http://puu.sh/2spff[/img]
How can I make it add up all the cities population respectively to arrive at each city being presented once?
For example, it would show Melbourne as 50,000 (20,000+30,000)
[cpp]
SELECT DISTINCT(C.CITYNAME), W.CAPACITY
FROM CITY C
INNER JOIN WAREHOUSE W ON C.CITYCODE = W.CITYCODE
WHERE W.CAPACITY >=10000
[/cpp]
[QUOTE=mobrockers2;40128972][cpp]
SELECT DISTINCT(C.CITYNAME), W.CAPACITY
FROM CITY C
INNER JOIN WAREHOUSE W ON C.CITYCODE = W.CITYCODE
WHERE W.CAPACITY >=10000
[/cpp][/QUOTE]
I've tried that before, just tried it again to make sure it doesn't work. I get this:
[img]http://puu.sh/2sqzG[/img]
[QUOTE=SammySung;40129011]I've tried that before, just tried it again to make sure it doesn't work. I get this:
[img]http://puu.sh/2sqzG[/img][/QUOTE]
Derped
[cpp]
SELECT C.CITYNAME, W.CAPACITY
FROM CITY C
INNER JOIN WAREHOUSE W ON C.CITYCODE = W.CITYCODE
WHERE W.CAPACITY >=10000
GROUP BY CITYCODE
[/cpp]
Btw why are your database elements in uppercase?
[QUOTE=mobrockers2;40128512]WHERE .. LIKE '%st' AND .. LIKE '%rd'
[editline]2nd April 2013[/editline]
MySQL isn't pure sql :v:[/QUOTE]
I meant something like "Are you using php or something of the likes to achieve this, or just mysql"
I kinda thought he meant it like selecting rows that have names that end with 'st' or 'rd'.
[QUOTE=mobrockers2;40129043]Derped
[cpp]
SELECT C.CITYNAME, W.CAPACITY
FROM CITY C
INNER JOIN WAREHOUSE W ON C.CITYCODE = W.CITYCODE
WHERE W.CAPACITY >=10000
GROUP BY CITYCODE
[/cpp]
Btw why are your database elements in uppercase?[/QUOTE]
Wouldn't you need to select SUM( W.CAPACITY ) ? If not could you explain why it works?
[QUOTE=Kamshak;40129830]Wouldn't you need to select SUM( W.CAPACITY ) ? If not could you explain why it works?[/QUOTE]
Im.. Uh.. Yes I believe you're right.
Today is not a good day.
I have an IDE problem...
[code]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
[/code]
So when I copy paste it's { and }, but in IDE it shows [ and ], and when I try to type { or } it transforms into [ and ]...
My brother wants to make games in Unity but he has no idea how to program. What's a good absolute beginner's guide to c# that he can use online?
[QUOTE=aurum481;40131645]I have an IDE problem...
[code]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
[/code]
So when I copy paste it's { and }, but in IDE it shows [ and ], and when I try to type { or } it transforms into [ and ]...[/QUOTE]
Might want to tell us which IDE perhaps?
[QUOTE=mobrockers2;40131854]Might want to tell us which IDE perhaps?[/QUOTE]
Oh yeah... Seems to happen in both Visual Studio and Eclipse.
Need some help with this rotation... I have 2 16x16 sprites, a player and a weapon, I am setting the weapons position and rotation to the same as the player, but I am not getting the expected result. This is what it looks like without rotation, but position ( correct ):
[IMG]http://i.imgur.com/I3pxBDR.png[/IMG]
this is what happens as I rotate around. I suspect it has something to do with the center of rotation but changing it didn't seem to do much.
[IMG]http://i.imgur.com/ea5CfVD.png[/IMG]
[IMG]http://www.adamncasey.co.uk/upload/image/4330/d/o/[/IMG]
OpenGL problem:
I know the x,y of each sharp point, how do I smooth them down?
[QUOTE=Duskling;40132272]Need some help with this rotation... I have 2 16x16 sprites, a player and a weapon, I am setting the weapons position and rotation to the same as the player, but I am not getting the expected result. This is what it looks like without rotation, but position ( correct ):
[IMG]http://i.imgur.com/I3pxBDR.png[/IMG]
this is what happens as I rotate around. I suspect it has something to do with the center of rotation but changing it didn't seem to do much.
[IMG]http://i.imgur.com/ea5CfVD.png[/IMG][/QUOTE]
maybe you should blit the player model and its weapon onto a seperate sprite and then just rotate and blit that
At first I was stumped why it happened in 2 different IDEs but then it hit me - the IDEs weren't broken, it was the font that was broken... Apparently something messed up Courier New font IDEs were using.
[QUOTE=duno;40136949][IMG]http://www.adamncasey.co.uk/upload/image/4330/d/o/[/IMG]
OpenGL problem:
I know the x,y of each sharp point, how do I smooth them down?[/QUOTE]
I haven't done this before, but you could take 3 points along the path, and add in points between the two outermost ones along a curve (spline? bezier?) that uses the middle point as the curve extent. Depending on how sharp the curve is, the result could either turn into an amorphous blob of green, or something that still resembles the original shape.
Gonna ask a question.
Where should I start learning Python? I only want to learn the basic shit so I have sort of a headstart when I start learning it at school.
I have some experience with doing things in Batch.
So, I'm trying to re-create Terraria in Python ( Lol I know, Python, really? ) but yeah, I'm mostly doing it since everyone seems to think it'd be impossible. Anyway, I have it functioning with over 20 million blocks rendering at 60 FPS right now, but it's only a flat terrain. My issue is, I have no idea how to go about generating mountains, caves, etc. If anyone could point me in the right direction, it'd be greatly appreciated.
[QUOTE=matthall765;39982232]Quick C# questionI have VS2012, and working with a MySQL DB. I have all the connections and everything, now I just need to find one thing. I had it, but Visual Studio decided to hide it again. It is the control where you can take a table from the DB, and drag it into the form, as either a table adapter or binded textboxes / lables, and adds all the necessary table adapters, binding sources etc. Do any of you know where the hell M$ hides it?[/QUOTE] Forgot I posted this, the solution is View - Other Windows - Data Sources or Shift + Alt + D
[QUOTE=Blasphemy;40152470]So, I'm trying to re-create Terraria in Python ( Lol I know, Python, really? ) but yeah, I'm mostly doing it since everyone seems to think it'd be impossible. Anyway, I have it functioning with over 20 million blocks rendering at 60 FPS right now, but it's only a flat terrain. My issue is, I have no idea how to go about generating mountains, caves, etc. If anyone could point me in the right direction, it'd be greatly appreciated.[/QUOTE]
You can blend noise and gradients to create terrain. [URL="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html"]This chapter from GPU Gems 3[/URL] is in 3D but you can apply the same principle to 2D.
here's a page on doing it in 2d
[url]http://webstaff.itn.liu.se/~stegu/TNM022-2005/perlinnoiselinks/perlin-noise-math-faq.html[/url]
i don't understand it though
Sorry, you need to Log In to post a reply to this thread.