zoukankan      html  css  js  c++  java
  • 333

    package lbbbbb;
    
    public class Student {
        String name;
        char sex;
        String number;
        int age;
        int score[]=new score[5];
        public void Student(){
        System.out.println("姓名:"+name+"性别:"+sex+"学号:"+number+"年龄:"+age);
        for(int i=0;i<5;i++){
            System.out.println("成绩"+i+":"+score[5]);
        }
        double a;
        a=(score[0]+score[1]+score[2]+score[3]+score[4])/5;
        System.out.println("平均成绩:"+a);
    }
    }
    package lbbbbb;
    import java.util.*;
    public class TestSdudent {
    
        public static void main(String[] args) {
    Student s1 =new Student();
    Scanner ll
    =new Scanner(System.in);
    println("请输入学生的姓名,性别,学号,年龄“);
    s1.name=ll.next(); s1.sex=ll.nextChar(); s1.number=ll.next(); s1.age=ll.nextInt();
    for(int i=1;i<6;i++){
    println("请输入第"+i+"门课程的成绩:");
    s1.score[i-1]=ll.nextInt(); } }

     6.1 “借书卡”类
    属性:账号、持卡人姓名、身份证号码、地址、已借书数、可借书数、本次借书数、本次还书数
    方法一:借书,显示本次借书数和可借书数
    方法二:还书,显示本次还书数和可借书数
    6.2 测试类
    本次借书数 和 本次还书数,从键盘输入
    源代码:
    “借书卡”类

    package Luli;
    
    public class Book {
        String name;
        int number;
        String editor;
        String publish;
        String time;
        int page;
        float price;
       public Book(String name,int number,String editor,String publish,String time,int page,float price){
          this.name=name;
          this.number=number;
          this.editor=editor;
          this.publish=publish;
          this.time=time;
          this.page=page;
          this.price=price;
          System.out.println(name+","+number+","+editor+","+publish+","+time+","+page+","+price);
    }

    测试类

    package lbbbbb;
    
    import java.util.Scanner;
    
    public class Tbook {
    
        public static void main(String[] args) {
            Scanner rd=new Scanner(System.in);
            book s1=new book();
            System.out.println("请输入本次借书数和本次还书数:");
             s1.bcjss=rd.nextInt();
             s1.bchss=rd.nextInt();
             s1.id=123456;
             s1.name="雨田牙西";
             s1.num="430456159635785212";
             s1.address="湖南长沙";
             s1.yjss=2;//已借书数
             s1.kjss=10;//可借书数
             s1.borrow();
             s1.repay();
        }
        }

    结果

    编写“电费管理类”及其测试类。
    7.1 “借书卡”类
    属性:上月电表读数、本月电表读数
    方法一:显示上月、本月电表读数
    方法二:计算本月用电数
    方法三:显示本月用电数
    方法四:假设每度电的价格为2元,计算并显示本月电费
    7.2 测试类
    上月电表读数、本月电表读数,从键盘输入
    “借书卡”类:

    package luli;
    public class electricity {
        int s;
        int c;
        public void bbb() {
             System.out.println("上月电表读数:"+s+"本月电表读数:"+c);
             System.out.println("本月用电数:"+(c-s));
             System.out.println("本月电费:"+(c-s)*2);
         }

    测试类

    package luli;
    import java.util.*;
    public class testelectricity {
        public static void main(String[] args) {
            Scanner rd=new Scanner(System.in);
            electricity s1=new electricity();
            System.out.println("请输入上月电表读数和本月电表读数:");
            s1.s=rd.nextInt();
            s1.c=rd.nextInt();
            s1.bbb();
            }
    }

    编写“四则运算类”及其测试类。
    8.1 应用场景
    计算器。能实现简单的四则运算,要求:只进行一次运算。
    8.1 “四则运算”类
    属性:操作数一、操作数二、操作符
    方法一:对两个操作数做加运算
    方法二:对两个操作数做减运算
    方法三:对两个操作数做乘运算
    方法四:对两个操作数做除运算
    8.2 测试类
    从键盘输入两个操作数和一个操作符,计算之后,输出运算结果
    源代码:
    “四则运算”类:

    package luli;
    public class number {
        int a1;
        int a2;
        char b;
    public void add() {
            System.out.println(a1+a2);
    }
    public void reduce() {
            System.out.println(a1-a2);
    }
    public void multiplication() {
            System.out.println(a1*a2);
    }
    public void division() {
            System.out.println(a1/a2);
    }
    }

    测试类

    package luli;
    import java.util.*;
    public class testnumber {
         public static void main(String[] args) {
            Scanner rd=new Scanner(System.in);
            number s=new number();
            System.out.println("请输入两个操作数和一个操作符:");
            s.a1=rd.nextInt();
            s.a2=rd.nextInt();
            s.b=rd.next().charAt(0);
            if(s.b=='+')
            s.add();
            else if(s.b=='-')
            s.reduce();
            else if(s.b=='*')
            s.multiplication();
            else if(s.b=='/')
            s.division();   
          }
    }

    编写“用户”类及其测试类。
    9.1 应用场景
    大多数的软件都需要“用户管理功能”,需要创建“用户类”。此程序实现了简易的“登录”功能,即验证用户名和密码是否正确。
    9.2“用户”类:
    属性:用户名、密码
    方法1:查找用户名是否存在(请将已注册的用户信息保存在数组中),用户存在返回true,不存在返回false
    方法2:验证密码是否正确,正确返回true,不正确返回false
    9.3 测试类
    从键盘输入用户名和密码
    用户名、密码均正确,在控制台输出“登录成功”
    用户名不存在,在控制台输出“用户名不存在”
    密码不正确,在控制台输出“密码不正确”
    源代码:
    “用户”类:

    package luli; 
    public class person {
        String a[]={"ll"};
        String b[]= {"123456"};
        String xingming;
        String mima;
       public boolean xingming() {
            for(int i=0;i<a.length;i++) {
                if(xingming.equals(a[i]))
                     return true;
            }
            return false;
         }
       public boolean mima() {
           for(int i=0;i<b.length;i++) {
            if(mima.equals(b[i]))
                 return true;
           }
           return false;
       }
    }

    测试类

    package luli;
    import java.util.*;
    public class testperson {
       public static void main(String[] args) {
           Scanner rd=new Scanner(System.in);
           person s=new person();
           System.out.println("请输入用户名和密码:");
           s.xingming=rd.next();
           s.mima=rd.next();
           if(s.xingming()==true&&s.mima()==true)
               System.out.println("登录成功!");
           else if(s.xingming()==false&&s.mima()==true)
               System.out.println("用户名不存在!");
           else if(s.xingming()==true&&s.mima()==false)
               System.out.println("密码不正确!");
        }
    }

  • 相关阅读:
    PDI的steps:(8:Avro input)
    Expert Cube Development with Microsoft SQL Server 2008 Analysis Services(1)
    PDI的steps:(6:Analytic Query)
    PDI的steps:(5:Add value fields changing sequence)
    Junk dimensions
    PDI的steps:(8:Automatic Documentation Output)
    PDI的steps:(5:Add XML)
    PDI的steps:(7:Append streams)
    Expert Cube Development with Microsoft SQL Server 2008 Analysis Services(2)度量值和度量值组
    Expert Cube Development with Microsoft SQL Server 2008 Analysis Services(3) 第一章
  • 原文地址:https://www.cnblogs.com/luli1220/p/10722426.html
Copyright © 2011-2022 走看看