① 3、 用java定义一个股票类Stock,该类包括如右图所示
public
class
stock
{
private
string
store;//
股票类属性
private
string
symbol;//
股票代号
private
string
name;//
股票名称
private
bigdecimal
currentprice;//
当前时间的股票价格
private
bigdecimal
previouclosingprice;//
前一天的股票值
/**
*
返回前一天变到当前时间的百分比
*
@return
百分比
*/
public
double
getchangepercent()
{
return
this.currentprice.subtract(this.previouclosingprice).abs()
.divide(this.currentprice,
2,
bigdecimal.round_half_even)
.doublevalue();
}
/**
*
返回前一天变到当前时间的百分比
*
@param
currentprice
当前时间的股票价格
*
@param
previouclosingprice
前一天的股票值
*
@return
百分比
*/
public
double
getchangepercent(bigdecimal
currentprice,
bigdecimal
previouclosingprice)
{
return
currentprice.subtract(previouclosingprice).abs()
.divide(currentprice,
2,
bigdecimal.round_half_even)
.doublevalue();
}
public
string
getstore()
{
return
store;
}
public
void
setstore(string
store)
{
this.store
=
store;
}
public
string
getsymbol()
{
return
symbol;
}
public
void
setsymbol(string
symbol)
{
this.symbol
=
symbol;
}
public
string
getname()
{
return
name;
}
public
void
setname(string
name)
{
this.name
=
name;
}
public
bigdecimal
getcurrentprice()
{
return
currentprice;
}
public
void
setcurrentprice(bigdecimal
currentprice)
{
this.currentprice
=
currentprice;
}
public
bigdecimal
getpreviouclosingprice()
{
return
previouclosingprice;
}
public
void
setpreviouclosingprice(bigdecimal
previouclosingprice)
{
this.previouclosingprice
=
previouclosingprice;
}
}
② 定义一个股票类Stock
定义股票的类:
在类模块中输入下列代码。
public symbol as string
public name as string
public currenprice as currency
public sub 显示股票信息()
msgbox(symbol & vbcrlf & name & currency)
end sub
打印图案
private sub print()
dim x as string
dim y as integer
dim z as integer
x=""
for i=0 to 2
y=2-i
z=1+i*2
for j=1 to y
x=x & " "
nex j
for j=1 to z
x=x & "#"
next j
x=x & vbcrlf
next i
msgbox(x)
end sub
没有看到第8题,第7题与股票的问题类似。
本例是用VB答复的,其他语言基本类似。
原来是要Java的:
public class Stock {
private String symbol;
private String name;
private double currentPrice;
public Stock(){
}
public void display(){
System.out.println("(" + this.symbol + ")" + this.name + ":" + this.currentPrice);
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getCurrentPrice() {
return currentPrice;
}
public void setCurrentPrice(double currentPrice) {
this.currentPrice = currentPrice;
}
}
③ 用C++设计一个股票信息的程序
要写的完美还比较有难度,很想帮你写,但是没有充足的时间!
④ java数组自定义的问题
public class Stock
{
public static void main(String[] args)
{
Stock s=new Stock("ORCL","Oracle Corporation ",34.5);
s.setCurrentPrice(34.35);
System.out.println(s.getChangePercent() );
}
Stock(String symbol,String name,double previousClosingPrice)
{
this.symbol=symbol;
this.name=name;
this.previousClosingPrice=previousClosingPrice;
}
String getChangePercent()
{
String s="%";
double t=((currentPrice-previousClosingPrice)/previousClosingPrice);
if(t<0)
{
s="-%";
t=-t;
}
return s+t*100;
}
void setCurrentPrice(double currentPrice)
{
this.currentPrice=currentPrice;
}
private String symbol,name;
private double previousClosingPrice,currentPrice;
}
⑤ 想建一个关于股票分析的网站,想请教高手策划指点下
简单想弯弯 弄个博客或者微薄就可以了.
要想做好 就网络设计以及服务器需要很大规模
要想做好
一 要容纳所有股票
二 建立股票分类
三 建立股票群体
四 个股票有自己的独立新闻 传说 以及评论 人事财务 总是需要和股票的软件想沟通 把资料调集过来
五 建立一个股票分析群体 把股票类别以及 分析资料 综合显示 以及类别显示 以及各自显示
六 投资人可以很快进行相互沟通 这个相互沟通 可以分类别 以及股票群体 以及股票各自独立的集体
因此就是建立一个再线群体聊天空间 在这个=空间 关注的是三个聊天室窗口 外带一个自己独立建立的好友群体聊天室 因此是四个聊天室
如何来运用和关注呢 需要好好思索下
好友以及股票群友进行股票 分析 以及专业人群的友情加入进行的团体分析 分析分类别 各自股票 以及大盘
目前很多股票网都不具备灵活的群体分析 仅仅是专业人事分析 他们分析很多都是被超控手法
因为你买的时候是高价格也在上升 你一放或者割天就完蛋了
⑥ 用java定义一个股票类Stock,该类包括如右图所示
public class Stock {
private String store;// 股票类属性
private String symbol;// 股票代号
private String name;// 股票名称
private BigDecimal currentPrice;// 当前时间的股票价格
private BigDecimal previouClosingPrice;// 前一天的股票值
/**
* 返回前一天变到当前时间的百分比
* @return 百分比
*/
public double getChangePercent() {
return this.currentPrice.subtract(this.previouClosingPrice).abs()
.divide(this.currentPrice, 2, BigDecimal.ROUND_HALF_EVEN)
.doubleValue();
}
/**
* 返回前一天变到当前时间的百分比
* @param currentPrice 当前时间的股票价格
* @param previouClosingPrice 前一天的股票值
* @return 百分比
*/
public double getChangePercent(BigDecimal currentPrice,
BigDecimal previouClosingPrice) {
return currentPrice.subtract(previouClosingPrice).abs()
.divide(currentPrice, 2, BigDecimal.ROUND_HALF_EVEN)
.doubleValue();
}
public String getStore() {
return store;
}
public void setStore(String store) {
this.store = store;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BigDecimal getCurrentPrice() {
return currentPrice;
}
public void setCurrentPrice(BigDecimal currentPrice) {
this.currentPrice = currentPrice;
}
public BigDecimal getPreviouClosingPrice() {
return previouClosingPrice;
}
public void setPreviouClosingPrice(BigDecimal previouClosingPrice) {
this.previouClosingPrice = previouClosingPrice;
}
}
⑦ 编写一个类Stock表示股票,成员变量有: string型symbol,表示股票代码. String型name,表示股票名称. double
其实这种最基础的题目,你自己想一下就做出来了。
public class Stock {
private String symbol;
private String name;
private double currentPrice;
public Stock(){
}
public void display(){
System.out.println("(" + this.symbol + ")" + this.name + ":" + this.currentPrice);
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getCurrentPrice() {
return currentPrice;
}
public void setCurrentPrice(double currentPrice) {
this.currentPrice = currentPrice;
}
}
⑧ c++程序设计题:定义一个股票类(stock)对象数组,存放连续5个交易日的股票信息,计算股票涨幅。
#include<iostream>
usingnamespacestd;
intmain()
{
doublestock[5];//定义长度为5的数组存放用户输入的股票价格
for(inti=0;i<5;i++)
{
cin>>stock[i];
}//循环读入用户输入的股价
doublepercent=(stock[4]-stock[0])*100;
cout<<"涨幅:"<<percent<<"%"<<endl;
return0;
}
⑨ 用c++ 定义一个类Stock,记录一支股票交易的基本信息。
#include<iostream.h>
#include<graphics.h>
class Stock{
public:
Stock(int o,int h,int l,int c)
{
close=c;
open=o;
low=l;
high=h;
}
private:
int high;
int low;
int open;
int close;
};
int main()
{
Stock st(5,5.5,5,5.5);
Stock yesterday;
drawline(st); //未定义实现
yesterday=st;//有待您改进ing。
return 0;
}
⑩ java 设计一个Stock的类,这个类包括:
代码如下:
importjava.math.BigDecimal;
importjava.math.RoundingMode;
publicclassStock{
privateStringsymbol;
privateStringname;
;
privatedoublecurrentPrice;
//构造方法
publicStock(Stringsymbol,Stringname){
this.symbol=symbol;
this.name=name;
}
//
publicdoublegetChangePercent(){
return(currentPrice-previousClosingPrice)/previousClosingPrice;
}
(doublepreviousClosingPrice){
this.previousClosingPrice=previousClosingPrice;
}
publicvoidsetCurrentPrice(doublecurrentPrice){
this.currentPrice=currentPrice;
}
publicStringgetSymbol(){
returnsymbol;
}
publicStringgetName(){
returnname;
}
publicstaticvoidmain(String[]args){
Stockstock=newStock("Java","SunMircro");
stock.setCurrentPrice(4.35);//当前价格
stock.setPreviousClosingPrice(4.5);//前一交易日价格
doubled=stock.getChangePercent();//价格浮动:由于是double,下面的计算是N位小数
System.out.println("价格浮动:"+stock.getChangePercent());
//处理下
BigDecimalbd=newBigDecimal(d*100);//乘个100,是为了看效果
bd=bd.setScale(2,RoundingMode.HALF_UP);//设置2位小数,采用四舍五入
System.out.println("["+stock.getSymbol()+"]"+stock.getName()+"价格浮动:"+bd.toString()+"%");
}
}
亲,如果回答满意,亲及时采纳,你的合作是我们回答的动力,谢谢!