java编程题附带代码 java编程题目( 三 )


public class _1 {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String zifuchuan = new String("");
int hanzishu = 0;
int zimu = 0;
int kongge = 0;
int shuzi = 0;
int qita = 0;
System.out.print("请输入一行字符:");
BufferedReader stdin = new BufferedReader(new InputStreamReader(
System.in));
zifuchuan = stdin.readLine();
byte[] bytes = zifuchuan.getBytes();
for (int i = 0; ibytes.length; i++) {
if ((bytes[i] = 65bytes[i] = 90)
|| (bytes[i] = 97bytes[i] = 122))
zimu++;
else if (bytes[i] == 32)
kongge++;
else if (bytes[i] = 48bytes[i] = 57)
shuzi++;
else if (bytes[i]0)
hanzishu++;
else
qita++;
}
System.out.println("字符串所占字节个数为:" + bytes.length);
System.out.println("汉字个数为:" + hanzishu / 2);
System.out.println("英文字母个数为:" + zimu);
System.out.println("空格个数为:" + kongge);
System.out.println("数字个数为:" + shuzi);
System.out.println("其他字符个数为:" + qita);
}
}
java编程题求找错,以下是完整代码public double wl(double wl){ //改为 wltze()
wl=z*(Math.pow(1+(nl/1200),12*n));
return wl;
}
public String wl() {
// TODO Auto-generated method stub
return "未来投资额为 "+wl(); //改为 return "未来投资额为 "+wltze();
}
}
请求大神帮我解答这道java编程题(填写代码)此题的Employee类设计有缺陷,缺少员工薪水的属性 。根据题意只能写出下面的程序:
abstract class Employee {
public abstract double earnings();
}
class YearWorker extends Employee {
@Override
public double earnings() {
return 0;
}
}
class MonthWorker extends Employee {
@Override
public double earnings() {
return 0;
}
}
class WeekWorker extends Employee {
@Override
public double earnings() {
return 0;
}
}
class Company {
Employee[] employee;
double salaries = 0;
Company(Employee[] employee) {
this.employee = employee;
}
public double salariesPay() {
salaries = 0;
//计算salaries
for(int i=0; iemployee.length; i++) {
salaries += employee[i].earnings();
}
return salaries;
}
}
public class HardWork {
public static void main(String[] args) {
Employee[] employee = new Employee[20];
for(int i=0; iemployee.length; i++) {
if(i % 3 == 0) {
employee[i] = new YearWorker();
}
else if(i % 3 == 1) {
employee[i] = new MonthWorker();
}
else if(i % 3 == 2) {
employee[i] = new WeekWorker();
}
}
Company company = new Company(employee);
System.out.println("公司年工资总额:" + company.salariesPay());
}
}
运行结果:
公司年工资总额:0.0
java编程题?以下是一个简单java编程题附带代码的HTML网页java编程题附带代码,包含一个文本框和一个按钮,点击按钮后,将文本框中的文字改变为红色:
!DOCTYPE html
html
headtitle修改文本框颜色/title
scriptfunction changeColor() {
var text = document.getElementById("text").value;document.getElementById("text").style.color = "red";
}/script
/headbody
input type="text" id="text"brbrbutton onclick="changeColor()"确定/button/body/html
这个网页包含两个元素:一个输入框和一个按钮 。点击按钮后,调用changeColor()函数 , 该函数首先获取文本框中的文本 , 然后将其颜色设置为红色,从而实现java编程题附带代码了修改文本框颜色的功能 。

推荐阅读