java設計一個期貨價格展示板
㈠ 使用JAVA 編寫一個程序,顯示5中商品價格,用戶可以選擇多種商品並在其後的文本框輸入購買的數量。
聽你的意思,有文本框輸入,像是html的東西,不是java,代碼如下,效果圖,
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript">
function a(){
var a = document.getElementById("apple").value;
document.getElementById("a").innerText=a*5;
}
function b(){
var b = document.getElementById("banana").value;
document.getElementById("b").innerText=b*6;
}
function o(){
var o = document.getElementById("orange").value;
document.getElementById("o").innerText=o*7;
}
function p(){
var p = document.getElementById("potato").value;
document.getElementById("p").innerText=p*8;
}
function f(){
var f = document.getElementById("fish").value;
document.getElementById("f").innerText=f*20;
}
</script>
<body onload="a(),b(),o(),p(),f()">
蘋果 :<span>單價:5元</span><input type="text" name="apple" id="apple" onblur="a()" value="1"/><span id="a"></span><br><br>
香蕉 :<span>單價:6元</span><input type="text" name="banana" id="banana" onblur="b()" value="1"/><span id="b"></span><br><br>
橙子 :<span>單價:7元</span><input type="text" name="orange" id="orange" onblur="o()" value="1"/><span id="o"></span><br><br>
西紅柿:<span>單價:8元</span><input type="text" name="potato" id="potato" onblur="p()" value="1"/><span id="p"></span><br><br>
魚 :<span>單價:20元</span><input type="text" name="fish" id="fish" onblur="f()" value="1"/><span id="f"></span><br><br>
</body>
</html>
㈡ 如何通過報表實現如下圖所示的一個展示效果(採用Java技術)
可以自己通過Java的畫圖工具自己畫,也可以去找一些開源的圖標設計工具。如果是WEb項目的圖表可以用JfreeChart或者OpenFlashChart來做
㈢ 求助帖.做個java畢業設計程序大概多少錢
這個一般可能會根據畢設的具體內容來定,包括代碼量,復雜度等維度進行度量
㈣ . 設計一個Java程序,其功能是根據商品的價格輸出不同的信息:(使用switch – case結
輸出一個價格數據
然後通過switch語句在case中的一個區域內比較確定商品的價格再輸出
如果不想自己寫代碼的話支付寶5元可以幫你搞定
㈤ 求java解答,求編寫一個題,就是做一個菜單,要求有3個商品,要求輸入名字和價格,然後輸出出來,輸
importjava.io.File;
importjava.io.FileOutputStream;
importjava.io.OutputStream;
importjava.util.Scanner;
publicclassDemo02{
publicstaticvoidmain(String[]args)throwsException{
StringBuffersb=newStringBuffer();
Scannersc=newScanner(System.in);
for(inti=0;i<3;i++){
System.out.print("請輸入商品名字: ");
Stringname=sc.nextLine();
System.out.print("請輸入商品價格: ");
Stringprice=sc.nextLine();
sb.append("("+name+"/"+price+") ");
}
Filefile=newFile("C:\MyData.txt");
if(!file.exists()){
file.createNewFile();
}
OutputStreamos=newFileOutputStream(file);
byte[]bytes=sb.toString().getBytes();
os.write(bytes,0,bytes.length);
os.close();
sc.close();
}
}
㈥ 用java編寫一個小程序 輸入書名 價格點擊查詢按鈕 顯示廠家 這個代碼怎麼寫
那就看你怎麼想了,我給你幾個建議,因為我沒有時間幫你實現。
建議一:簡單實現法:你把每種書名、價格、廠家都作為一個對象的屬性分別存到不同的對象中,在主函數中首先用構造方法實例化這幾個對象,然後再用你輸入的字元串和每個對象的相應屬性一一比對,符合條件則輸出對應的廠家。
建議二:比較復雜實現法:信息全部保存到資料庫,然後再用你輸入的字元串和每條記錄的相應欄位一一比對,符合條件則輸出對應的廠家。
如果你對我真誠的回答滿意的話,請給我多加分,如果有什麼疑問的話,請給我留言。QQ也可以全天在線108424683.
㈦ 商城中商品展示頁按價格降序顯示怎樣用Java實現
你可以在sql中寫入兩個佔位符來代替默認值,然後判斷前台有沒有傳入這個值,如果沒有就傳入你寫好的默認值,如果有傳入價格區間值就使用這個傳入的值.
㈧ 請設計一個GUI界面,參考如下界面原型實現。求大神用JAVA
importjava.awt.Color;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.util.Random;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JPanel;
{
privateJButton[]btns=newJButton[7];
privateRandomrn=newRandom();
privateboolean[]flags=newboolean[33];//用來判別重復
publicMyPanel(){
init();
}
privatevoidinit(){
setTitle("MyPanel....");
setSize(540,250);
setContentPane(createPane());
}
privateJPanelcreatePane(){
JPanelpane=newJPanel(null);
pane.setBackground(Color.YELLOW);
for(inti=0;i<btns.length;i++){
btns[i]=newJButton("0");
btns[i].setBounds(20+(i*70),30,54,24);
btns[i].setBackground(Color.PINK);
pane.add(btns[i]);
btns[i].addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
while(true){
intn=rn.nextInt(34);
//如果數字被使用,或為3334就重新選數字
if(n==0||n>33||flags[n-1]){
continue;
}
//把使用了的數字設置為true,即已使用
flags[n-1]=true;
//把不用了的數字設置成未使用狀態
if(Integer.parseInt(((JButton)e.getSource())
.getText())!=0){
flags[Integer.parseInt(((JButton)e.getSource())
.getText())-1]=false;
}
((JButton)e.getSource()).setText(String.valueOf(n));
break;
}
}
});
}
JButtoncreNum=newJButton("創建數字");
creNum.setBounds(50,150,100,30);
creNum.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
for(inti=0;i<btns.length;i++){
while(true){
intn=rn.nextInt(34);
//如果數字被使用,或為3334就重新選數字
if(n==0||n>33||flags[n-1]){
continue;
}
//把使用了的數字設置為true,即已使用
flags[n-1]=true;
//把不用了的數字設置成未使用狀態
if(Integer.parseInt(btns[i].getText())!=0){
flags[Integer.parseInt(btns[i].getText())-1]=false;
}
btns[i].setText(String.valueOf(n));
break;
}
}
}
});
pane.add(creNum);
JButtonsort=newJButton("排序");
sort.setBounds(200,150,100,30);
sort.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
//排序
String[]strs=newString[7];
//把按鈕上面的數字拿出來
for(inti=0;i<btns.length;i++){
strs[i]=btns[i].getText();
}
//開始排序
for(inti=strs.length-1;i>0;i--){
for(intj=0;j<i;j++){
if(Integer.parseInt(strs[i])<Integer
.parseInt(strs[j])){
Stringtemp;
temp=strs[i];
strs[i]=strs[j];
strs[j]=temp;
}
}
}
//排好,在顯示到按鈕上
for(intj=0;j<strs.length;j++){
btns[j].setText(strs[j]);
}
}
});
pane.add(sort);
JButtonreset=newJButton("重置");
reset.setBounds(350,150,100,30);
reset.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
flags=newboolean[33];
for(inti=0;i<btns.length;i++){
btns[i].setText("0");
}
}
});
pane.add(reset);
returnpane;
}
publicstaticvoidmain(String[]args){
MyPanelmp=newMyPanel();
mp.setVisible(true);
}
}
根據你的要求,數字不會重復,用的是冒泡排序
希望對你有幫助
如圖:
㈨ 用java設計一個簡單的界面設計,越簡單越好,謝謝
用java設計一個簡單的界面可以參考如下實例:
importjavax.swing.JFrame;//框架
importjavax.swing.JPanel;//面板
importjavax.swing.JButton;//按鈕
importjavax.swing.JLabel;//標簽
importjavax.swing.JTextField;//文本框
importjava.awt.Font;//字體
importjava.awt.Color;//顏色
importjavax.swing.JPasswordField;//密碼框
importjava.awt.event.ActionListener;//事件監聽
importjava.awt.event.ActionEvent;//事件處理
importjavax.swing.JOptionPane;//消息窗口{
publicJPanelpnluser;
publicJLabellbluserLogIn;
publicJLabellbluserName;
publicJLabellbluserPWD;
publicJTextFieldtxtName;
publicJPasswordFieldpwdPwd;
publicJButtonbtnSub;
publicJButtonbtnReset;
publicUserLogIn(){
pnluser=newJPanel();
lbluserLogIn=newJLabel();
lbluserName=newJLabel();
lbluserPWD=newJLabel();
txtName=newJTextField();
pwdPwd=newJPasswordField();
btnSub=newJButton();
btnReset=newJButton();
userInit();
}
publicvoiserInit(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設置關閉框架的同時結束程序
this.setSize(300,200);//設置框架大小為長300,寬200
this.setResizable(false);//設置框架不可以改變大小
this.setTitle("用戶登錄");//設置框架標題
this.pnluser.setLayout(null);//設置面板布局管理
this.pnluser.setBackground(Color.cyan);//設置面板背景顏色
this.lbluserLogIn.setText("用戶登錄");//設置標簽標題
this.lbluserLogIn.setFont(newFont("宋體",Font.BOLD|Font.ITALIC,14));//設置標簽字體
this.lbluserLogIn.setForeground(Color.RED);//設置標簽字體顏色
this.lbluserName.setText("用戶名:");
this.lbluserPWD.setText("密碼:");
this.btnSub.setText("登錄");
this.btnReset.setText("重置");
this.lbluserLogIn.setBounds(120,15,60,20);//設置標簽x坐標120,y坐標15,長60,寬20
this.lbluserName.setBounds(50,55,60,20);
this.lbluserPWD.setBounds(50,85,60,25);
this.txtName.setBounds(110,55,120,20);
this.pwdPwd.setBounds(110,85,120,20);
this.btnSub.setBounds(85,120,60,20);
this.btnSub.addActionListener(newActionListener()//匿名類實現ActionListener介面
{
publicvoidactionPerformed(ActionEvente){
btnsub_ActionEvent(e);
}
}
);
this.btnReset.setBounds(155,120,60,20);
this.btnReset.addActionListener(newActionListener()//匿名類實現ActionListener介面
{
publicvoidactionPerformed(ActionEvente){
btnreset_ActionEvent(e);
}
}
);
this.pnluser.add(lbluserLogIn);//載入標簽到面板
this.pnluser.add(lbluserName);
this.pnluser.add(lbluserPWD);
this.pnluser.add(txtName);
this.pnluser.add(pwdPwd);
this.pnluser.add(btnSub);
this.pnluser.add(btnReset);
this.add(pnluser);//載入面板到框架
this.setVisible(true);//設置框架可顯
}
publicvoidbtnsub_ActionEvent(ActionEvente){
Stringname=txtName.getText();
Stringpwd=String.valueOf(pwdPwd.getPassword());
if(name.equals("")){
JOptionPane.showMessageDialog(null,"賬號不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}elseif(pwd.equals("")){
JOptionPane.showMessageDialog(null,"密碼不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}elseif(true){
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"賬號或密碼錯誤","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}
}
publicvoidbtnreset_ActionEvent(ActionEvente){
txtName.setText("");
pwdPwd.setText("");
}
publicstaticvoidmain(String[]args){
newUserLogIn();
}
}
㈩ 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()+"%");
}
}
親,如果回答滿意,親及時採納,你的合作是我們回答的動力,謝謝!