------------恢复内容开始------------
前言
本次分析的题目集是本学期前三次PTA题目集。其中,第一次PTA题目集共有九道题目共100分,我有八道题目成功提交通过,还有一道题目有一个测试点未能成功通过,扣除两分,得98分;第二次PTA题目集共有四道题目共100分,我仅有一道题目成功提交通过,剩下三道题目中第二题未能写出来,第三题仅得三分,第四题仅得九分,共得42分;第三次PTA题目集共有七道题目共100分,我有五道题目成功提交通过,第一题未能写出,得零分,第六题仅得5分。
三次作业集在知识点上由简单到复杂,难度上也是由易到难,逐层递进。但由于我第完成二次题目集时学习情况较差,故得分最低。而在面对第三次题目集的7-1题,即菜单系列题目的第三道题时,我感到束手无策。这也是我认为在三次PT题目集中难度最大的一道题目。
第一次题目集的题目涉及到的知识点完全集中在JAVA语言程序设计设计基础的部分。考察的内容主要有键盘录入、选择结构、循环结构、控制台打印、数据类型、JAVA关键字和运算符等等。
第二次题目集中首次出现了有关类和对象的题目,即7-1和7-2两道菜单题。这两道题目对于当时的我来说相当高,以至于我仅仅完成了7-1一道题,第二题得零分。
第三次题目集我受到第二次题目集的影响,菜单题7-1同样未能完成。值得一提的是,这一次的题目集中的第四、第五和第六道题同样需要用到对象和类的思想,还涉及到了面向对象三大特征之一的封装特性。
设计与分析
第一次题目集7-1是一道编程题,要求根据身高和体重计算BMI,判断人的体重状态。
分析解题思路:输入身高和体重数据,需要判断数据是否在合法范围内,如果数据超出范围则输出“input out of range”,否则进行BMI值计算。根据所计算出的BMI值,判断体重状态,输出不同的状态字符串。
import java.util.*;
public class Main {
public static void main(String[] args) {
double high;
double weight;
double BMI;
Scanner in = new Scanner(System.in);
weight = in.nextDouble();
high = in.nextDouble();
BMI = weight / (high * high);
if (high <= 0 || high > 2.72 || weight <= 0 || weight > 727)
{
System.out.println("input out of range");
}
else
{
if(BMI<18.5)
{
System.out.println("thin");
}
if(BMI>=18.5&&BMI<24)
{
System.out.println("fit");
}
if(BMI>=24&&BMI<28)
{
System.out.println("overweight");
}
if(BMI>=28)
{
System.out.println("fat");
}
}
}
}
![]()
![]()
我在写这道题目时使用了多个if语句选择结构,使得程序可以根据输入数据的不同输出不同的结果。其中尤其需要注意的是超出范围的数据。
第一次题目集第二题是一道字符串处理题目,要求根据学号输出各个信息的完整说明。
分析解题思路:输入学号,需要判断输入的字符串长度是否为8位,前两位是否为入学年份的后两位数字,第3、4位是否为合法的学院编号,否则输出“Wrong Format”。根据学号的各个部分,输出对应的说明信息。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String mac;
String year,col,cla,num;
Scanner in = new Scanner(System.in);
mac = in.next();
if(8!=mac.length()) {
System.out.print("Wrong Format");
return;
}
year = mac.substring(0,2);
col = mac.substring(2,4);
cla = mac.substring(4,6);
num = mac.substring(6,8);
if(col.equalsIgnoreCase("01")) {
col = "材料学院";
}else if(col.equalsIgnoreCase("02")) {
col = "机械学院";
}else if(col.equalsIgnoreCase("03")) {
col = "外语学院";
}else if(col.equalsIgnoreCase("20")) {
col = "软件学院";
}else {
System.out.print("Wrong Format");
return;
}
System.out.print("入学年份:20"+year+"年\n"
+ "学院:"+col+"\n"
+ "班级:"+cla+"\n"
+ "学号:"+num);
}
}![]()
这道题目第一次出现字符串,还用到了mac.substring( )方法
第一次题目集的最后一道题是简单的几何题目,要求根据三角形的三边的长短关系,判断其类型。
分析解题思路:输入三角形的三条边,需要判断输入的数据是否符合要求,如果输入数据不是三个实数,或其中存在负数、0或超出范围[1,200]的数值,则输出“Wrong Format”,否则继续进行下一步判断。判断输入的三个数值是否能够组成三角形。如果不能,则输出“Not a triangle”,否则继续进行下一步判断。根据三角形的三边长,判断其类型,输出对应的说明。
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner (System.in);
boolean Isosceles=false,RT=false;
double a,b,c;
a = in.nextDouble();
b = in.nextDouble();
c = in.nextDouble();
if(a<1||a>200||b<1||b>200||c<1||c>200) {
System.out.print("Wrong Format");
return;
}
if(a+b<=c||a+c<=b||b+c<=a) {
System.out.print("Not a triangle");
return;
}
if(a==b&&a==c&&b==c) {
System.out.print("Equilateral triangle");
return;
}
if(a==b||a==c||b==c) {
Isosceles = true;
}
if(Math.abs(a*a+b*b-c*c)<0.000001||Math.abs(a*a+c*c-b*b)<0.000001||Math.abs(c*c+b*b-a*a)<0.000001) {
RT = true;
}
if(Isosceles&&RT) {
System.out.print("Isosceles right-angled triangle");
}else if(Isosceles) {
System.out.print("Isosceles triangle");
}else if(RT) {
System.out.print("Right-angled triangle");
}
}
}
![]()
这道题目是我在这次题目集中唯一未能得到满分的题目。这道题目的最后一个测试点“一般三角形测试”我始终没有通过。这也是我一直以来的疑问。
第二次题目集的第一道题目是菜单系列题目的第一道题。它比第一次题目集中的题目都要更加的复杂,首次涉及到了面向对象程序设计的思想。
import java.util.Scanner;
class Dish {
String name;
int unit_price;
// 构造函数
Dish(String name, int price) {
this.name = name;
this.unit_price = price;
}
// 计算菜品价格
int getPrice(int portion) {
int price = 0;
switch (portion) {
case 1:
price = unit_price;
break;
case 2:
price = (int) Math.round(unit_price * 1.5);
break;
case 3:
price = unit_price * 2;
break;
}
return price;
}
}
class Menu {
Dish[] dishes;
// 构造函数
Menu() {
dishes = new Dish[4];
dishes[0] = new Dish("西红柿炒蛋", 15);
dishes[1] = new Dish("清炒土豆丝", 12);
dishes[2] = new Dish("麻婆豆腐", 12);
dishes[3] = new Dish("油淋生菜", 9);
}
// 根据菜名查找菜品
Dish searchDish(String name) {
for (Dish d : dishes) {
if (d.name.equals(name)) {
return d;
}
}
return null;
}
}
class Record {
Dish dish;
int portion;
// 构造函数
Record(Dish dish, int portion) {
this.dish = dish;
this.portion = portion;
}
// 计算本条记录的价格
int getPrice() {
return dish.getPrice(portion);
}
}
class Order {
Record[] records;
int size;
// 构造函数
Order() {
records = new Record[100];
size = 0;
}
// 添加一条记录
Record addARecord(String dishName, int portion) {
Menu menu = new Menu();
Dish dish = menu.searchDish(dishName);
if (dish == null) {
System.out.println(dishName + " does not exist");
return null;
}
Record record = new Record(dish, portion);
records[size++] = record;
return record;
}
// 计算订单总价
int getTotalPrice() {
int totalPrice = 0;
for (int i = 0; i < size; i++) {
totalPrice += records[i].getPrice();
}
return totalPrice;
}
}
public class Main {
public static void main(String[] args) {
Order order = new Order();
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
while (!line.equals("end")) {
String[] tokens = line.split(" ");
String dishName = tokens[0];
int portion = Integer.parseInt(tokens[1]);
order.addARecord(dishName, portion);
line = scanner.nextLine();
}
int totalPrice = order.getTotalPrice();
System.out.println(totalPrice);
}
}
这次的代码中首次出现了类的定义以及构造函数。
这次题目集中的第二题我未能得到哪怕一分,所以我无法拿出自己的源码进行分析。但我可以尝试分析这道题目。
这是一道比较复杂的题目,需要设计多个类,进行不同功能的封装。
分析解题思路:
定义Dish类,对应菜单中一道菜品信息。
Dish {
String name;//菜品名称
int unit_price; //单价
int getPrice(int portion)//计算菜品价格的方法,输入参数是点菜的份额(输入数据只能是1/2/3,代表小/中/大份) }
定义Menu类,对应菜单的信息。
Menu { Dish[] dishs ;//菜品数组,保存所有菜品信息 Dish searthDish(String dishName)//根据菜名在菜谱中查找菜品信息,返回Dish对象。 Dish addDish(String dishName,int unit_price)//添加一道菜品信息 }
定义Record类,对应订单中一条菜品记录。
Record { int orderNum;//序号
Dish d;//菜品
int portion;//份额(1/2/3代表小/中/大份)
int getPrice()//计价,计算本条记录的价格
}
定义Order类,对应整个订单信息。
Order { Record[] records;//菜品记录数组,保存所有点菜记录 void addRecord(int orderNum,String dishName,int portion)//添加一条菜品记录 void deleteRecord(int orderNum)//删除一条菜品记录 void print()//输出整个订单的信息 int getTotalPrice()//计算所有菜品的价格之和 }
最后在主函数中按照题目要求调用各个类的方法,完成整个程序。
最后我找同学要来了他的高分代码
import java.util.Scanner;
public class Main{
public static boolean isNumeric(String string) {
int intValue;
try {
intValue = Integer.parseInt(string);
return true;
} catch (NumberFormatException e) {
return false;
}
}
public static void main(String[] args){
Menu menu = new Menu();
Order order = new Order();
Scanner input = new Scanner(System.in);
String str1 = new String();
String str2 = new String();
int portion=0,quota=0;
int menu_count=0,order_count=0;
int i=0,sum=0,flag=0;
while(true){
str1 = input.next();
if(isNumeric(str1))break;
if(str1.equals("end"))break;
str2 = input.next();
for(i=0;i<menu_count;i++){
if(menu.dishs[i].name.equals(str1)){menu.dishs[i].unit_price=Integer.parseInt(str2);
flag++;
break;
}
}
if(flag==0){menu.dishs[menu_count] = new Dish();
menu.dishs[menu_count] = menu.addDish(str1,Integer.parseInt(str2));
menu_count++;
}
flag=0;
}
while(true){
if(str1.equals("end"))break;
str2 = input.next();
if(str2.equals("delete")){
if(order.delARecordByOrderNum(Integer.parseInt(str1),order_count))
order_count--;
str1 = input.next();
if(str1.equals("end"))break;
}
else {portion = input.nextInt();
quota = input.nextInt();
if(menu.searchDish(str2,menu_count)!=-1){
order.records[order_count] = new Record();
order.records[order_count] = order.addARecord(Integer.parseInt(str1),str2,portion,quota,menu_count,menu);
order_count++;
}
else System.out.println(str2+" does not exist");
str1 = input.next();
}
}
for(i=0;i<order_count;i++){
sum+=order.records[i].getPrice(order.records[i]);
}
System.out.println(sum);
}
static class Dish{
String name;
int unit_price;
}
static class Record{
int orderNum;
Dish d;
int portion;
int quota;
int getPrice(Record record){
if(record.portion==2)return (int) Math.round(1.5*record.d.unit_price)*record.quota;
else if(record.portion==3)return 2*record.d.unit_price*record.quota;
else return record.d.unit_price*record.quota;
}
}
static class Menu{
Dish[] dishs = new Dish[20];
int searchDish(String dishName,int count){
for(int i=0;i<count;i++){
if(dishName.equals(dishs[i].name)){
return i;
}
}
return -1;
}
Dish addDish(String dishName,int unit_price){
Dish newDish = new Dish();
newDish.name = dishName;
newDish.unit_price = unit_price;
return newDish;
}
}
static class Order{
Record[] records = new Record[20];
Record addARecord(int orderNum,String dishName,int portion,int quota,int count,Menu menu){
Record newRecord = new Record();
newRecord.orderNum = orderNum;
newRecord.d=menu.dishs[menu.searchDish(dishName,count)];
newRecord.portion = portion;
newRecord.quota = quota;
System.out.println(newRecord.orderNum + " "+newRecord.d.name +" "+newRecord.getPrice(newRecord));
return newRecord;
}
boolean delARecordByOrderNum(int orderNum,int count){
// Record[] temp = new Record[20];
// int i=0,j=0,flag=0;
// for(i=0;i<count;i++){
// if(records[i].orderNum==orderNum){
// flag++;
// continue;
// }
// temp[j]=records[i];
// j++;
// }
// if(flag==0){System.out.println("delete error;");return false;}
// else records=temp;
// return true;
int i=0,j=0,flag=0;
for(i=0;i<count;i++){
if(records[i].orderNum==orderNum){
for(j=i;j<count-1;j++){
records[j]=records[j+1];
}
flag++;
}
}
if(flag==0){System.out.println("delete error;");return false;}
return true;
}
}
}
![]()
第三次题目集的第一题也是菜单系列题目的第三题,相较于之前的题目是远远更加复杂的。
这道题需要设计多个类,包括菜品类、菜谱类、点菜记录类、订单类。其中,菜品类需要保存菜品的名称和单价,并提供计算菜品价格的方法。
题目要求我们设计四个类:菜品类、菜谱类、点菜记录类、订单类。其中,菜品类需要保存菜品的名称和单价,并提供计算菜品价格的方法;菜谱类需要保存所有菜品的信息,并提供查找和添加菜品的方法;点菜记录类需要保存订单上的一道菜品记录,并提供计价的方法;订单类需要保存用户点的所有菜品信息,并提供计算订单总价、添加记录和删除记录的方法。
我们可以先设计好这些类的属性和方法:
菜品类:
- String name:菜品名称
- BigDecimal price:菜品单价
- BigDecimal getPrice(int portion):计算指定份额的菜品价格
菜谱类:
- Map<String, Dish> dishes:保存所有菜品信息
- void addDish(Dish dish):添加菜品
- Dish getDish(String name):根据菜名查找菜品
点菜记录类:
- int id:订单号
- Dish dish:点菜的菜品
- int portion:份额
- int count:份数
- BigDecimal getPrice():计算该记录的价格
订单类:
- int tableNum:桌号
- List<OrderItem> items:保存所有点菜记录
- BigDecimal getTotalPrice():计算订单总价
- void addOrderItem(OrderItem item):添加点菜记录
- void deleteOrderItem(int id):删除指定订单号的点菜记录
接下来,我们可以按照输入格式逐行读入数据,并根据不同的数据类型进行相应的处理:
- 如果读入的是菜品信息,则创建Dish对象,并将其添加到菜谱中
- 如果读入的是点菜记录,则根据菜名查找菜品信息,创建OrderItem对象,并将其添加到订单中
- 如果读入的是删除记录,则根据订单号删除相应的点菜记录
- 如果读入的是end,则输出处理结果,并清空订单信息
在具体实现时,我们可以使用Map来保存菜谱中的菜品信息,使用List来保存订单上的点菜记录。对于计价和总价的计算,可以使用BigDecimal类,以避免精度问题。在输出结果时,可以使用StringBuilder来拼接字符串,以提高效率。同时,为了保证代码的可读性和可维护性,我们可以将一些重复使用的代码封装成方法,并使用注释来说明代码的作用。需要注意代码的命名规范和缩进风格,以提高代码的可读性。
总之,这道题需要设计多个类,并涉及到大量数据处理,需要仔细分析题目要求和数据格式,设计好各个类的属性和方法,并按照输入格式逐行读入数据,根据不同的数据类型进行相应的处理。在实现代码时,需要注意代码的可读性和可维护性,避免出现精度问题和逻辑错误。
最后还是我同学的代码
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.Scanner;
public class Main{
public static boolean isNumeric(String string) {
int intValue;
try {
intValue = Integer.parseInt(string);
return true;
} catch (NumberFormatException e) {
return false;
}
}
public static void main(String[] args) throws ParseException{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH/mm/ss");
Menu menu = new Menu();
Table[] tables = new Table[20];
Scanner input = new Scanner(System.in);
String str1 = new String();
String str2 = new String();
String time = new String();
int menu_count=0,table_count=0;
int i=0,flag=0;
int portion = 0,quota = 0;
while(true){//输入菜单
str1 = input.next();
if(str1.equals("table"))break;
if(str1.equals("end"))break;
str2 = input.next();
for(i=0;i<menu_count;i++){
if(menu.dishs[i].name.equals(str1)){menu.dishs[i].unit_price=Integer.parseInt(str2);
flag++;
break;
}
}
if(flag==0){menu.dishs[menu_count] = new Dish();
menu.dishs[menu_count] = menu.addDish(str1,Integer.parseInt(str2));
menu_count++;
}
flag=0;
}
while(!str1.equals("end")){
tables[table_count] = new Table();
str2 = input.next();
time = input.nextLine();
Date date = new Date();
date= sdf.parse(time);
Instant instant = date.toInstant();
ZoneId zone = ZoneId.systemDefault();
tables[table_count].time= LocalDateTime.ofInstant(instant, zone);
System.out.println("table "+(table_count+1)+": ");
while(true) {
str1 = input.next();
if(str1.equals("end"))break;
if(str1.equals("table"))break;
str2 = input.next();
if(isNumeric(str2)) {
System.out.print(Integer.parseInt(str2)+" table " + (i+1) +" pay for table "+Integer.parseInt(str1)+" ");
Record treat = new Record();
str1 = input.next();
treat.d = menu.dishs[menu.searchDish(str1,menu_count)];
portion = input.nextInt();
quota = input.nextInt();
treat.portion = portion;
treat.quota = quota;
System.out.print(treat.getPrice() +"\n");
tables[table_count].sum+=treat.getPrice();
}
else {
if(!str2.equals("delete")) {
portion = input.nextInt();
quota = input.nextInt();
}
tables[table_count].od(menu,menu_count,str1,str2,portion,quota);
}
}
tables[table_count].getSum();
table_count++;
}
for(i=0;i<table_count;i++) {
if(tables[i].isOpen()) {
System.out.println("table "+(i+1)+": "+tables[i].sum);
}
else System.out.println("table " + (i+1)+ " out of opening hours");
}
}
static class Dish{
String name;
int unit_price;
}
static class Record{
int orderNum;
Dish d;
int portion;
int quota;
int getPrice(){
if(portion==2)return (int) Math.round(1.5*d.unit_price)*quota;
else if(portion==3)return 2*d.unit_price*quota;
else return d.unit_price*quota;
}
}
static class Menu{
Dish[] dishs = new Dish[20];
int searchDish(String dishName,int count){
for(int i=0;i<count;i++){
if(dishName.equals(dishs[i].name)){
return i;
}
}
return -1;
}
Dish addDish(String dishName,int unit_price){
Dish newDish = new Dish();
newDish.name = dishName;
newDish.unit_price = unit_price;
return newDish;
}
}
static class Order{
Record[] records = new Record[20];
Record addARecord(int orderNum,String dishName,int portion,int quota,int count,Menu menu){
Record newRecord = new Record();
newRecord.orderNum = orderNum;
newRecord.d=menu.dishs[menu.searchDish(dishName,count)];
newRecord.portion = portion;
newRecord.quota = quota;
System.out.println(newRecord.orderNum + " "+newRecord.d.name +" "+newRecord.getPrice());
return newRecord;
}
boolean delARecordByOrderNum(int orderNum,int count){
int i=0,j=0,flag=0;
for(i=0;i<count;i++){
if(records[i].orderNum==orderNum){
for(j=i;j<count-1;j++){
records[j]=records[j+1];
}
flag++;
}
}
if(flag==0){System.out.println("delete error;");return false;}
return true;
}
}
static class Table {
Order order = new Order();
int num;
int order_count=0;
LocalDateTime time ;
long sum=0;
void od(Menu menu,int menu_count,String str1,String str2,int portion,int quota){
if(str2.equals("delete")){
if(order.delARecordByOrderNum(Integer.parseInt(str1),order_count))
order_count--;
}
else {
if(menu.searchDish(str2,menu_count)!=-1){
order.records[order_count] = new Record();
order.records[order_count] = order.addARecord(Integer.parseInt(str1),str2,portion,quota,menu_count,menu);
order_count++;
}
else System.out.println(str2+" does not exist");
}
}
void getSum() {
int weekday = time.getDayOfWeek().getValue();
for(int i=0;i<order_count;i++) {
sum+=order.records[i].getPrice();
}
if(weekday>0&&weekday<6) {
if(time.getHour()>=17&&time.getHour()<20)sum=Math.round(sum*0.8);
if(time.getHour()==20) {
if(time.getMinute()<=30)sum=Math.round(sum*0.8);
}
if(time.getHour()>=10&&time.getHour()<14)sum=Math.round(sum*0.6);
if(time.getHour()==14) {
if(time.getMinute()<=30)sum=Math.round(sum*0.6);
}
}
}
boolean isOpen() {
int weekday = time.getDayOfWeek().getValue();
if(weekday>0&&weekday<6) {
if(time.getHour()>=17&&time.getHour()<20)return true;
if(time.getHour()==20) {
if(time.getMinute()<=30)return true;
}
if(time.getHour()>10&&time.getHour()<14)return true;
if(time.getHour()==10){
if(time.getMinute()>=30)return true;
}
if(time.getHour()==14) {
if(time.getMinute()<=30)return true;
}
}
else {
if(time.getHour()>9&&time.getHour()<21)return true;
if(time.getHour()==9) {
if(time.getMinute()>=30)return true;
}
if(time.getHour()==21) {
if(time.getMinute()<=30)return true;
}
}
return false;
}
}
}
![]()
踩坑心得
第一次题目集第二题我最初一直提交无法通过。直到后来在同学的提醒下我将输出的结果的数据类型强制转换为float型才最终通过。其实在编程时变量的数据类型的重要性往往被我忽视,但有时候题目就是会因为数据类型不正确而不达标。
第一次题目集的7-5我也在提交时遭遇了问题。最终在我反复的检查后发现我在运用选择结构if的嵌套时算法出现了问题,不同的if语句输出的内容有重复。
第一次题目集的7-7我在编写程序时一直没想到用Math类中的abs方法,所以我始终没有找到合适的表达式来完成if语句中的判断。甚至我还想过自己写一个方法来解决这个问题。直到我同学提醒我可以直接调用JAVA自带的方法。所以在之后的编程中我加大了对语言和开发软件的熟悉,从而提高了效率。
主要困难以及改进建议
现在我再回头看菜单系列题目的第一题7-1时,我可以对自己的代码做一些改进了
在 Order 类中,没有定义 size 和 records 数组,需要先定义并初始化。
在 addARecord 方法中,应该先判断该菜品是否已经存在于订单中,如果存在,则只需要更新份数,而不是添加一条新的记录。
在 getTotalPrice 方法中,应该先判断订单是否为空,如果为空,则直接返回 0,而不是抛出异常。
在 main 方法中,应该添加输入数据的格式检查,例如输入的份数是否为正整数。
在 main 方法中,应该添加异常处理机制,例如输入的菜品名称不存在时,应该提示用户重新输入。
而对于第二次题目集的第四题,我也有了更好的答案
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int m = scanner.nextInt();
int[] nums = new int[m];
for (int i = 0; i < m; i++) {
nums[i] = scanner.nextInt();
}
for (int i = 0; i < m; i++) {
System.out.println(getStepCount(nums[i]));
}
}
private static int getStepCount(int n) {
if (n == 1) {
return 1;
} else if (n == 2) {
return 2;
} else if (n == 3) {
return 4;
}
int[] dp = new int[n + 1];
dp[1] = 1;
dp[2] = 2;
dp[3] = 4;
for (int i = 4; i <= n; i++) {
dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3] + dp[i - 4];
}
return dp[n];
}
}
还有第三次作业的第六题,我在重新审题后发现自己当时没能拿到满分纯粹是因为没有好好看题,于是我重写了代码,这次的代码肯定能够通过测试点了。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int degree = scanner.nextInt();
int minute = scanner.nextInt();
double second = scanner.nextDouble();
double result = degree + (double)minute / 60 + second / 3600;
System.out.printf("%d°%d′%.2f″ = %.6f", degree, minute, second, result);
}
}
总结
这三次PTA题目集作为作业来说我认为是非常出色的。它做到了贴合教学、紧扣知识点(尤其是重点),让我学到了很多,发现了很多问题以及自己需要改进的地方。
三次作业的布置时间与我们课程的进度是大体上重合的,所以可以说是贴合教学。但不可否认的是,如果需要比较好的完成这几次作业,光靠课堂上学到的内容绝对是不够的。我们还必须在课外时间上抽出很多用来作为补充,一个非常典型例子就是一个题目中我们就需要用到哈希表。
三次作业非常鲜明地强调了我们学的知识重点。键盘录入与输出、选择、循环、一维数组这些基础的重点内容反复出现,在我们学到面向对象程序设计的内容后题目也立即跟进,拿出了菜单系列。让我巩固了课堂上所学的知识。
此外,我也通过这些题目发现了自己的很多缺点。首先是对面向对象思想的理解和运用非常浅薄而且生疏,这导致我在写菜单系列题目时有很多处理不了的问题。所以我必须加强对类和对象,封装、继承和多态思想的接受。然后就是编程上不能够掐住要害,我在完成作业时效率明显比其他同学要低,结果也要更差。
最后,我认为老师可以在布置作业时更多的考虑到学生的个人能力有限的情况,并据此对题目的难度做出适当调整。使学生可以循序渐进,逐渐掌握学习内容。