public static void main(String[] args) {
成都創(chuàng)新互聯(lián)主營郁南網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都App定制開發(fā),郁南h5微信小程序開發(fā)搭建,郁南網(wǎng)站營銷推廣歡迎郁南等地區(qū)企業(yè)咨詢
String st = "";
計(jì)算器 j = new 計(jì)算器();
boolean t = true;
while (t) {
System.out.print("請輸入計(jì)算代碼:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
st = br.readLine();
} catch (IOException ex) {
Logger.getLogger(計(jì)算器.class.getName()).log(Level.SEVERE, null, ex);
}
if (st.equals("end")) {
t = false;
} else if (!st.equals("")) {
j.處理(st);
}
}
}
public void 處理(String st) {
if (st.indexOf("+") != -1) {
加(符號處理(st, "+"));
} else if (st.indexOf("-") != -1) {
減(符號處理(st, "-"));
} else if (st.indexOf("*") != -1) {
乘(符號處理(st, "*"));
} else if (st.indexOf("/") != -1) {
除(符號處理(st, "/"));
}
}
public int[] 符號處理(String st, String s) {
int[] i = new int[2];
i[0] = Integer.parseInt(st.substring(0, st.indexOf(s)));
i[1] = Integer.parseInt(st.substring(st.indexOf(s) + 1));
return i;
}
public void 加(int x[]) {
System.out.println(x[0] + "+" + x[1] + "=" + (x[0] + x[1]));
}
public void 減(int[] x) {
System.out.println(x[0] + "-" + x[1] + "=" + (x[0] - x[1]));
}
public void 乘(int[] x) {
System.out.println(x[0] + "*" + x[1] + "=" + x[0] * x[1]);
}
public void 除(int x[]) {
if (x[1] == 0) {
System.out.print("除數(shù)不能為零");
return;
}
System.out.println(x[0] + "/" + x[1] + "=" + x[0] / x[1]);
}
可以運(yùn)行:輸入示例:55+62
具體如下:
連連看的小源碼
package Lianliankan;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianliankan implements ActionListener
{
JFrame mainFrame; //主面板
Container thisContainer;
JPanel centerPanel,southPanel,northPanel; //子面板
JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數(shù)組
JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕
JLabel fractionLable=new JLabel("0"); //分?jǐn)?shù)標(biāo)簽
JButton firstButton,secondButton; //
分別記錄兩次62616964757a686964616fe59b9ee7ad9431333335326239被選中的按鈕
int grid[][] = new int[8][7];//儲存游戲按鈕位置
static boolean pressInformation=false; //判斷是否有按鈕被選中
int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標(biāo)
int i,j,k,n;//消除方法控制
代碼(code)是程序員用開發(fā)工具所支持的語言寫出來的源文件,是一組由字符、符號或信號碼元以離散形式表示信息的明確的規(guī)則體系。
對于字符和Unicode數(shù)據(jù)的位模式的定義,此模式代表特定字母、數(shù)字或符號(例如 0x20 代表一個(gè)空格,而 0x74 代表字符“t”)。一些數(shù)據(jù)類型每個(gè)字符使用一個(gè)字節(jié);每個(gè)字節(jié)可以具有 256 個(gè)不同的位模式中的一個(gè)模式。
在計(jì)算機(jī)中,字符由不同的位模式(ON 或 OFF)表示。每個(gè)字節(jié)有 8 位,這 8 位可以有 256 種不同的 ON 和 OFF 組合模式。對于使用 1 個(gè)字節(jié)存儲每個(gè)字符的程序,通過給每個(gè)位模式指派字符可表示最多 256 個(gè)不同的字符。2 個(gè)字節(jié)有 16 位,這 16 位可以有 65,536 種唯一的 ON 和 OFF 組合模式。使用 2 個(gè)字節(jié)表示每個(gè)字符的程序可表示最多 65,536 個(gè)字符。
單字節(jié)代碼頁是字符定義,這些字符映射到每個(gè)字節(jié)可能有的 256 種位模式中的每一種。代碼頁定義大小寫字符、數(shù)字、符號以及 !、@、#、% 等特殊字符的位模式。每種歐洲語言(如德語和西班牙語)都有各自的單字節(jié)代碼頁。
雖然用于表示 A 到 Z 拉丁字母表字符的位模式在所有的代碼頁中都相同,但用于表示重音字符(如"é"和"á")的位模式在不同的代碼頁中卻不同。如果在運(yùn)行不同代碼頁的計(jì)算機(jī)間交換數(shù)據(jù),必須將所有字符數(shù)據(jù)由發(fā)送計(jì)算機(jī)的代碼頁轉(zhuǎn)換為接收計(jì)算機(jī)的代碼頁。如果源數(shù)據(jù)中的擴(kuò)展字符在接收計(jì)算機(jī)的代碼頁中未定義,那么數(shù)據(jù)將丟失。
如果某個(gè)數(shù)據(jù)庫為來自許多不同國家的客戶端提供服務(wù),則很難為該數(shù)據(jù)庫選擇這樣一種代碼頁,使其包括所有客戶端計(jì)算機(jī)所需的全部擴(kuò)展字符。而且,在代碼頁間不停地轉(zhuǎn)換需要花費(fèi)大量的處理時(shí)間。
package com.zpp;public class Charge {
public static void main(String [] args) {
if(args.length ==0) {
System.out.println("parameter error!");
System.out.println("java com.zpp.Charge [int]");
return;
}
int min = Integer.parseInt(args[0]);
double money = 0.0;
if (min = 0) {
money =0.0;
System.out.println("not money");
} else if (min = 60) {
money = 2.0;
} else {
money = 2.0 + (min - 60) * 0.01;
}
System.out.println("please pay: " + money);
}
} 編譯:javac -d . Charge.java運(yùn)行:java com.zpp.Charge 111
你想要什么程序呢?我給你一個(gè)示例,將一個(gè)字符串里面的大寫字母轉(zhuǎn)成小寫字母,或者將一個(gè)字符串的小寫字母轉(zhuǎn)成大寫字母:
import java.util.Scanner;
public class ToUpAndLow {
private static void ToUper(String str){
char strInput = 0;
int num = 0;
String outPutStr = "";
for (int i = 0; i str.length(); i++) {
strInput = str.substring(i,i + 1).charAt(0);
if(strInput = 97 strInput = 122){
num = strInput - 32;
outPutStr += String.valueOf((char)num);
} else {
outPutStr += String.valueOf((char)strInput);
}
}
System.out.println("該字符串的大寫形式是:" + outPutStr);
}
private static void ToLower(String str){
char strInput = 0;
int num = 0;
String outPutStr = "";
for (int i = 0; i str.length(); i++) {
strInput = str.substring(i,i + 1).charAt(0);
if(strInput = 65 strInput = 90){
num = strInput + 32;
outPutStr += String.valueOf((char)num);
} else {
outPutStr += String.valueOf((char)strInput);
}
}
System.out.println("該字符串的小寫形式是:" + outPutStr);
}
public static void main(String[] args) {
System.out.print("請輸入要轉(zhuǎn)換的字符串:");
String inputStr = new Scanner(System.in).next();
ToUper(inputStr);
ToLower(inputStr);
}
}
public class HelloWorld{
public static void main(String[] args){
System.out.println("hello world!");
}
}
一. 基本概念
Java是一種可以撰寫跨平臺應(yīng)用軟件的面向?qū)ο蟮某绦蛟O(shè)計(jì)語言。Java 技術(shù)具有卓越的通用性、高效性、平臺移植性和安全性,廣泛應(yīng)用于PC、數(shù)據(jù)中心、游戲控制臺、科學(xué)超級計(jì)算機(jī)、移動電話和互聯(lián)網(wǎng),同時(shí)擁有全球最大的開發(fā)者專業(yè)社群。
二. 體系
Java分為三個(gè)體系,分別為Java SE(J2SE,Java2 Platform Standard Edition,標(biāo)準(zhǔn)版),
JavaEE(J2EE,Java 2 Platform, Enterprise Edition,企業(yè)版)。
Java ME(J2ME,Java 2 Platform Micro Edition,微型版)。