本文目录一览:
- 西安电子科技大学java期末有上机考试吗?
- 救急啊!!!期末考试!怎样用JAVA的GUI(图形用户界面)来设计一个小程序!
- java期末考试!!求助!!!
- 大学java期末考试求求大家帮忙
- [从键盘输入期末考试成绩,求最高分、最低分、总分和平均分,并将成绩从高到低打印出来。 Java!求大神](#从键盘输入期末考试成绩,求最高分、最低分、总分和平均分,并将成绩从高到低打印出来。 Java!求大神)
- 高分求做简单JAVA期末考试
西安电子科技大学java期末有上机考试吗?
有上机考试。可以提前搜索了解历年的考试题目进行练习上机操作,根据导师上课的重点要求多复习。
救急啊!!!期末考试!怎样用JAVA的GUI(图形用户界面)来设计一个小程序!
给你找了一个,我试过,可以用
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.*;//GUI之前要吧这两个都引进来
public class Computer extends JFrame implements ActionListener {
JButton a1, a2, a3, a4, a5, a6, a7, a8, a9, a0;
JButton b1, b2, b3, b4;
JButton c1, c2, c3, c4;
JTextField t1, t2;
JPanel p1, p2;
JLabel bq1, bq2;
String fuhao;
Double count, count2;
boolean chose = false, cliks;
public static void main(String[] args) {
Computer l = new Computer();
}
public Computer() {
Font font = new Font("宋体", Font.BOLD, 36);
Font font2 = new Font("宋体", Font.BOLD, 20);
a1 = new JButton("1");
a1.setFont(font);
a1.addActionListener(this);
a2 = new JButton("2");
a2.setFont(font);
a2.addActionListener(this);
a3 = new JButton("3");
a3.setFont(font);
a3.addActionListener(this);
a4 = new JButton("4");
a4.setFont(font);
a4.addActionListener(this);
a5 = new JButton("5");
a5.setFont(font);
a5.addActionListener(this);
a6 = new JButton("6");
a6.setFont(font);
a6.addActionListener(this);
a7 = new JButton("7");
a7.setFont(font);
a7.addActionListener(this);
a8 = new JButton("8");
a8.setFont(font);
a8.addActionListener(this);
a9 = new JButton("9");
a9.setFont(font);
a9.addActionListener(this);
a0 = new JButton("0");
a0.setFont(font);
a0.addActionListener(this);
b1 = new JButton("清空");
b1.addActionListener(this);
b2 = new JButton("返回");
b2.addActionListener(this);
b3 = new JButton(".");
b3.addActionListener(this);
b4 = new JButton("=");
b4.addActionListener(this);
c1 = new JButton("+");
c1.addActionListener(this);
c2 = new JButton("-");
c2.addActionListener(this);
c3 = new JButton("x");
c3.addActionListener(this);
c4 = new JButton("÷");
c4.addActionListener(this);
t1 = new JTextField(25);
t2 = new JTextField(35);
t1.setFont(font2);
t2.setFont(font2);
p1 = new JPanel();
p2 = new JPanel();
bq1 = new JLabel("结");
bq2 = new JLabel("果");
p1.setLayout(new GridLayout(2, 3));
p2.setLayout(new GridLayout(4, 4));
p1.add(t1);
p1.add(b1);
p1.add(b2);
p1.add(t2);
p1.add(bq1);
p1.add(bq2);
p2.add(a1);
p2.add(a2);
p2.add(a3);
p2.add(c1);
p2.add(a4);
p2.add(a5);
p2.add(a6);
p2.add(c2);
p2.add(a7);
p2.add(a8);
p2.add(a9);
p2.add(c3);
p2.add(b3);
p2.add(a0);
p2.add(b4);
p2.add(c4);
this.add(p1, BorderLayout.NORTH);
this.add(p2, BorderLayout.CENTER);
this.setSize(460, 380);
this.setTitle("简易计算器");
this.setLocation(200, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
Object temp = e.getSource();
if (temp == a1) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "1");
chose = false;
}
if (temp == a2) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "2");
chose = false;
}
if (temp == a3) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "3");
chose = false;
}
if (temp == a4) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "4");
chose = false;
}
if (temp == a5) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "5");
chose = false;
}
if (temp == a6) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "6");
chose = false;
}
if (temp == a7) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "7");
chose = false;
}
if (temp == a8) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "8");
chose = false;
}
if (temp == a9) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "9");
chose = false;
}
if (temp == a0) {
if (chose == true) {
t1.setText("");
t2.setText("");
}
t1.setText(t1.getText() + "0");
chose = false;
}
if (temp == b3) {
cliks = true;
for (int i = 0; i < t1.getText().length(); i++) {
if ('.' == t1.getText().charAt(i)) {
cliks = false;
break;
}
if (cliks == true) {
t1.setText(t1.getText() + ".");
}
}
}
if (temp == c1) {
count = Double.parseDouble(t1.getText());
t1.setText("");
fuhao = "+";
}
if (temp == c2) {
count = Double.parseDouble(t1.getText());
t1.setText("");
fuhao = "-";
}
if (temp == c3) {
count = Double.parseDouble(t1.getText());
t1.setText("");
fuhao = "*";
}
if (temp == c4) {
count = Double.parseDouble(t1.getText());
t1.setText("");
fuhao = "÷";
}
if (temp == b1) {
t1.setText("");
t2.setText("");
}
if (temp == b2) {
String s = t1.getText();
t1.setText("");
for (int i = 0; i < s.length() - 1; i++) {
char a = s.charAt(i);
t1.setText(t1.getText() + a);
}
}
if (temp == b4) {
count2 = Double.parseDouble(t1.getText());
t1.setText("");
if (fuhao == "+") {
t1.setText(count + "" + fuhao + "" + count2 + "=");
t2.setText(count + count2 + "");
chose = true;
}
if (fuhao == "-") {
t1.setText(count + "" + fuhao + "" + count2 + "=");
t2.setText(count - count2 + "");
chose = true;
}
if (fuhao == "*") {
t1.setText(count + "" + fuhao + "" + count2 + "=");
t2.setText(count * count2 + "");
chose = true;
}
if (fuhao == "÷") {
if (count2 == 0) {
t1.setText(count + "" + fuhao + "" + count2 + "");
t2.setText("除数不能为0");
return;
}
t1.setText(count + "" + fuhao + "" + count2 + "=");
t2.setText(count / count2 + "");
chose = true;
}
}
}
}
java期末考试!!求助!!!
第一种:
- 当X=10时 X-1=X; 无效表达式
- 当X=10时 X-=3; 等价于 X=X-3; 运算后x的值:7
- 当X=10时 X*=1+2; 等价于 X=X*(1+2); 运算后x的值:30
- 当X=10时 X%=5; 等价于 X=X%5; 运算后x的值:0 第二种: 如果是问 X 经过后三个表达式运算后的值(第一个表达式是错的):
- X=X-3; 此时 X=7
- X=X*(1+2); 此时 X=21
- X=X%5; 此时 X=1 最后X为1
- 当a=6; b=-4;时 --a%++b; 等价于 (a-1)%(b+1); 运算后的值:2
- 当a=6; b=-4;时 (--a)a;; 等价于 (a-1)a; 运算后的值:160
- 位运算
- a-1的值为5
- 5的二进制为 101
- 5<<5 表示把五的二进制向左移动5位 即10100000换十进制为160
- 当a=6; b=-4;时 (a<10 && a>10 ? a:b); 等价于
- 如果a小于10 并且 a大于10 表达式的值为a也就是6 否则表达式的值为b 即-4
- 一个数不可能同时小于10又大于10 所以 表达式的值为b 也就是-4
大学java期末考试求求大家帮忙
%!
int a=20;
%
a+=2;%
a%
更多科目问题请追问
从键盘输入期末考试成绩,求最高分、最低分、总分和平均分,并将成绩从高到低打印出来。 Java!求大神
package test;
import java.util.Arrays;
import java.util.Scanner;
public class Chengji {
public static void main(String[] args) {
int Math;
int Phi;
int Eng;
Scanner scan = new Scanner(System.in);
System.out.println("[输入你的数学成绩]");
Math = scan.nextInt();
System.out.println("[请输入你的物理成绩]");
Phi = scan.nextInt();
System.out.println("[请输入你的英语成绩]");
Eng = scan.nextInt();
int[] arr = {Math, Phi, Eng};
int max = getMax(arr);
int min = getMin(arr);
double sum = getSum(arr);
Arrays.sort(arr);
System.out.println("最高分:" + max);
System.out.println("最低分:" + min);
System.out.println("平均分" + sum);
System.out.println("大到小的成绩为" + Arrays.toString(arr));
}
/**
* 取出数组中的最大值
* @param arr
* @return
*/
public static int getMax(int[] arr) {
int max = arr[0];
for (int i = 1; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
return max;
}
/**
* 取出数组中的最小值
* @param arr
* @return
*/
public static int getMin(int[] arr) {
int min = arr[0];
for (int i = 1; i < arr.length; i++) {
if (arr[i] < min) {
min = arr[i];
}
}
return min;
}
/**
* 取出数组中的平均值
* @param arr
* @return
*/
public static double getSum(int[] arr) {
double temp = 0;
double sum = 0;
for (int i = 1; i < arr.length; i++) {
sum += arr[i];
}
temp = sum / arr.length;
return temp;
}
}
高分求做简单JAVA期末考试
- Application 创建一个类,然后写一个主函数,再写一些程序在主函数里就是一个简单的Application Applet 创建一个类继承Applet类,然后实现init, start, destroy方法, 这个就可以了
- Java接口,Java语言中存在的结构,有特定的语法和结构; 包就是一个文件夹
- 多态包括重载和重构 最通俗的程序例子,昨天刚写的
/**
* 简单的通俗的讲:
* 继承就是儿子继承了父亲,一个类内有一个父亲,但一个父亲可以有多个儿子
* 多态就是儿子虽然继承了父亲的一些特性,但有些特性有了改变
* 封装就是有些东西儿子是父亲独有的儿子继承不了
*/
class FatherClass {
// FatherClass的成员变量
// 父亲公开的属性儿子,孙子,侄子都能访问 a
public int a;
// 父亲私有的属性,儿子继承不了,在子类中也不能访问 b
private int b;
// FatherClass的成员方法
// 父亲公开的方法儿子,孙子,侄子都能访问 eat
public void eat() {
System.out.println("Father eat!");
}
public void drink() {
System.out.println("Father drinking!");
}
// 父亲私有的方法,儿子继承不了,在子类中也不能访问 方法height
private void height() {
System.out.println("Father height!");
}
// 父亲的最终方法poor,也就是说儿子不能覆盖这个方法(儿子不能有和父亲方法头一样的函数)
public final void poor() {
System.out.println("Father poor!");
}
}
class SubClass extends FatherClass {
// 虽继承了父亲的吃方法,但儿子又拓展了父亲的吃方法,要带餐具(多态中的一:重载)
public void eat(String tool) {
System.out.println(tool + " :Son eat!");
}
// 和父亲的喝方法一样,不过这是儿子自己的喝方法,不是从父亲那里来的(多态中的二:覆盖或重写或重构)
public void drink() {
System.out.println("Son drinking!");
}
public static void print() {
System.out.println("Static Function!");
}
}
public class ExtendsTest {
public static void main(String[] args) {
SubClass sc = new SubClass();
sc.eat(); // 儿子继承了父亲的吃方法,可以直接使用
sc.eat("Bowl"); // 虽然儿子继承了父亲的吃方法,可是儿子也有自己的吃方法(拓展了),得用餐具吃
sc.drink(); // 这里调用的是儿子的喝方法而不是父亲的噢,父亲的被儿子覆盖了
// sc.height(); // 父亲私有的儿子不能使用
SubClass.print(); // 静态方法直接使用 类名.方法名 调用
}
}
- 面向对象特征:继承,多态,封装
import java.util.Scanner;
public class CountNum {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入一个整数:");
int number = sc.nextInt();
int sum = 0;
for (int i = 1; i <= number; i++) {
sum += i;
}
System.out.println("1+2+...+number=" + sum);
}
}
public class Student {
private long id;
private String name;
private int age;
boolean sex;
String phone;
public Student(long i, String n, int a, boolean s, String p) {
this.id = i;
this.name = n;
this.age = a;
this.sex = s;
this.phone = p;
}
int getage() {
return age;
}
boolean getsex() {
return sex;
}
Long getphone() {
return Long.parseLong(phone);
}
public String tostring() {
return name;
}
}
还不多呢
总算弄完了,,
呵呵…………
祝你好运哈。。。