⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 markfinding2.java

📁 一些Java的小的应用程序
💻 JAVA
字号:

import java.io.*;
public class Markfinding2 {
 public static void main(String[] args) {
  
  PrintWriter output2=null;
  try
  {
   output2=new PrintWriter(new FileOutputStream("suiji.txt"));
  }
  catch(FileNotFoundException e)
  {
   System.out.println("Error opening the file shunxu.txt.");
      System.exit(0);
  }
  char answer='y';
  int hao; String line1=null;
  while (answer!='n')
  {
     System.out.println("" + " 请输入学号.");
     hao=SavitchIn.readLineInt();
     output2.println(hao);
     System.out.println("输入姓名,性别");
     line1=SavitchIn.readLine();
     output2.print("  "+line1);
     int pingjun,n,sum=0,x=1;
     while (x<=10)
      {
     System.out.println("输入十门功课成绩.");
     n=SavitchIn.readLineInt();
        output2.print("  "+n);
        sum=sum+n;
        x++;
     }
  pingjun=sum/10;
  output2.println("  "+pingjun);
  System.out.println(" continue(y/n)");
  answer=SavitchIn.readLineNonwhiteChar();}
  output2.close();
  System.out.println("   输入完毕.");
  BufferedReader input1=null;
  try
  {
   input1=new BufferedReader(new FileReader("suiji.txt"));
     }
  catch(FileNotFoundException e)
  {
   System.out.println("Error opening the file suiji.txt.");
      System.exit(0);
  }
  boolean kongzhi=true;  int n=1,x,xuehao; String line2,line3;
  try
  {
   System.out.println("输入要查找的学生学号:");
      xuehao=SavitchIn.readLineInt();
      if(xuehao<=0)
      {
       System.out.println("该学号不存在.");
          System.exit(0);
      }
  line2=input1.readLine();
  x=Integer.parseInt(line2);
  line3=input1.readLine();
  while ((line2!=null)&&(kongzhi))
  {
   if (x==xuehao)
   kongzhi=false;
      else
       {
       line2=input1.readLine();
          line3=input1.readLine();
          n++;}
       }
     if(kongzhi==false)
   System.out.println(line2+line3);
     else 
      System.out.println("该学号不存在.");
         input1.close();}
     catch (IOException e)
      {
      System.out.println("Error reading from file shunxu.txt.");
   }
      System.out.println("end of the programm.");
   
  }
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -