java电话卡设计代码,java电话卡设计代码大全
有九道JAVA与面向对象的实践题目不会做啊!求高手把代码给我下可以吗?谢谢啦
7.
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了呼图壁免费建站欢迎大家使用!
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ";quot;
html
head
title计算器/title
style type="text/css"
input{
height:1.5em;}
.style1{
font-size:18px}
.height{
height:1.2em;}
/style
script language="javascript"
function computer(op){
var num1,num2,result;
num1 = parseFloat(document.form1.textname1.value);
num2 = parseFloat(document.form1.textname2.value);
if(op=="+")
result = num1 + num2;
document.form1.textResult.value=result;
if(op=="-")
result = num1 - num2;
document.form1.textResult.value = result;
if(op=="*")
result = num1 * num2;
document.form1.textResult.value = result;
if(op=="/" num2!=0)
result = num1/num2;
document.form1.textResult.value = result;
}
/script
/head
body
form name="form1"
center
table width="500" height="300" border="0" background="images/water001.jpg"
tr
td width="183" height="61"img src="images/baidu_logo.gif" width="182" height="54"//td
td width="219"span class="style1"百度计算器/span/td
/tr
tr
td colspan="2"span class="style1"第一个数:input type="text" name="textname1"//span/td
/tr
tr
td colspan="2"span class="style1"第二个数:input type="text" name="textname2"//span/td
/tr
tr
td colspan="2"
input class="height" type="button" value=" + " onClick="computer('+')"/nbsp;nbsp;nbsp;
input class="height" type="button" value=" - " onClick="computer('-')"/nbsp;nbsp;nbsp;
input class="height" type="button" value=" * " onClick="computer('*')"/nbsp;nbsp;nbsp;
input class="height" type="button" value=" / " onClick="computer('/')"/
/td
/tr
tr
td colspan="2"span class="style1"计算结果:input type="text" name="textResult"//span/td
/tr
/table
/center
/form
/body
/html
用java编写一个电话计费卡程序
import java.util.Scanner;
public class PhoneCard {
private final int id; // 卡号
private final int password; //密码
private double cash; //剩余金额
private double cashPerMin = 0.2;// 每分钟收费
private Scanner sc = new Scanner(System.in);
public PhoneCard(int id,int password,double cash) {
this.id = id;
this.password = password;
this.cash = cash;
}
/**
* 拨号计费
* @param time 拨号时间 单位分钟
* 返回剩余金额
*/
public double callSomeone(double time) {
System.out.println("请输入卡号和密码,用空格隔开");
int id = sc.nextInt();
int pw = sc.nextInt();
if(this.id == id this.password == pw) {
this.cash = this.cash - (double)time * cashPerMin;
return cash;
} else {
System.out.println("密码错误");
return -1;
}
}
}
public class TestPhoneCard {
public static void main(String[] args) {
PhoneCard pc = new PhoneCard(1, 1, 100); //初始化,卡号,密码,余额
double money = pc.callSomeone(10); //拨打10分钟
System.out.println("余额为" + money + "元");
money = pc.callSomeone(90); //继续拨打
System.out.println("余额为" + money + "元");
}
}
不知道为什么没人做
求一个记录人名和电话号码功能的Java应用程序
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Scanner;
public class Phones {
public static final String filename = "phonesnumber.txt";
public static void main(String[] args) throws Exception {
Phones p = new Phones();
p.getPhones();
while (true)
p.addPhone();
}
private String getInput(String tip) {
System.out.print(tip);
Scanner sc = new Scanner(System.in);
return sc.next();
}
public void getPhones() throws Exception {
File file = new File(filename);
if (!file.exists()) {
file.createNewFile();
return;
}
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
public void addPhone() throws Exception {
String name = getInput("请输入名字:");
String phone = getInput("请输入电话号码:");
BufferedWriter bw = new BufferedWriter(new FileWriter(
new File(filename), true));
bw.write(name + " " + phone + "\r\n");
bw.close();
}
}
JAVA小程序 设计一个电话卡
class PhoneCard
{
long can;
int ps;
double ba;
String con;
boolean connected=false;
PhoneCard(long cardNumber, int password,double balance,String connectNumber)
{
can=cardNumber;
ps=password;
ba=balance;
con=connectNumber;
}
void performConnection(long cardNumber, int password)
{
if(can!=cardNumber)
System.out.println("号码不对");
else if(can==cardNumberps!=password)
System.out.println("密码不对");
else if(can==cardNumberps==password)
{
this.getBalance();
connected=true;
this.performDial();
}
}
public double getBalance()
{
if(ba=0)
{
System.out.println("余额不足!");
System.exit(0);
}
else
return ba;
return ba;
}
double performDial()
{
System.out.println("本次通话将扣除0.5元");
return ba-0.5;
}
}
public class call1
{
public static void main(String[] args)
{
PhoneCard phonecard=new PhoneCard(88888888,123456,100.00,"110");
phonecard.performConnection(11111111,45);
phonecard.performConnection(88888888,45);
phonecard.performConnection(88888888,123456);
phonecard.getBalance();
}
};
java智能卡作业,电子钱包,用eclipse能运行的代码
//测试类
public class Util {
public static void main(String[] args) {
DianZiMoneyBao d1 = new DianZiMoneyBao(20,"123");
d1.syso(d1);
}
}
class DianZiMoneyBao{
public float money;//钱
public String miyue;
public DianZiMoneyBao(float money, String miyue){
this.money = money;
this.miyue = miyue;
}
//键盘输入方法
public static void syso(DianZiMoneyBao dzmb){
java.util.Scanner sc = new java.util.Scanner(System.in);
System.out.println("请输入功能,(1,加钱 2,减钱)");
String num = sc.next();
try{
if("1".trim().equals(num)){
System.out.println("请输入密钥....");
String miyue = sc.next();
if(miyue.equals(dzmb.miyue)){
System.out.println("卡内余额:" + dzmb.money+"元。");
System.out.println("请输入加钱金额,例如:20.05 / 20");
float f = sc.nextFloat();
dzmb.add(f);
}else{
System.out.println("对不起,输入密钥有误~!");
}
}else if("2".trim().equals(num)){
System.out.println("请输入密钥....");
String miyue = sc.next();
if(miyue.equals(dzmb.miyue)){
System.out.println("卡内余额:" + dzmb.money+"元。");
System.out.println("请输入提现金额,例如:20.05 / 20");
float f = sc.nextFloat();
dzmb.jian(f);
}else{
System.out.println("对不起,输入密钥有误~!");
}
}else{
System.out.println("对不起,输入类别错误~!");
}
}catch(Exception e){
System.out.println("请输入正确的金额...");
}
}
//加钱方法
public void add(float num){
System.out.println("加钱后余额:" + (this.money + num));
}
//减钱方法
public void jian(float num){
if(this.money - num = 0){
System.out.println("对不起,卡内余额为"+this.money+"元,不能提现~!");
}else{
System.out.println("提取后余额:" + (this.money - num));
}
}
}
JAVA设计查询用户电话
这其实关系到你的电话是如何人存储的,于是我只能提供一个示范代码:
package test;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Query {
private MapString, String phonebook;
public Query() {
phonebook = new HashMapString, String();
phonebook.put("qcq", "15363849333");
phonebook.put("qcq1", "15363849335");
phonebook.put("qcq2", "15363849338");
phonebook.put("qcq3", "15363849353");
}
public Query(MapString, String phonebook) {
this.phonebook = phonebook;
}
public String getPhoneByName(String name) {
if (phonebook.containsKey(name)) {
return phonebook.get(name);
} else {
return null;
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Query query = new Query();
System.out.println("please input the query name");
String name = in.next();
System.out.println(query.getPhoneByName(name));
if (null != in) {
in.close();
}
}
}
网站标题:java电话卡设计代码,java电话卡设计代码大全
转载注明:http://pwwzsj.com/article/dsijeip.html