import java.util.Scanner;
public class xiaoming {
public static void main(String[] args) {
xiaoming bi = new xiaoming();
System.out.println("小明可购买的笔数是:" + bi.Bi());
}
public int Bi() {
int shuibi = 0; //定义并初始化可购买水笔变量
int money = 0; //定义并初始化购买水笔所携带的钱
Scanner sc = new Scanner(System.in);
System.out.println("请输入小明携带钱数:");
money = sc.nextInt(); //控制台输入携带钱数
int temp = 0; //设立一个临时变量存储携带钱数除以单价的值
temp = money/5;
if(temp>=5 & temp<20) {
int i =0;
i = temp/5;
shuibi = i+temp;
}else if(temp < 5 & temp>=0) {
shuibi = temp;
}else if(temp >= 20 ){
int i = 0;
int j = 0;
i = temp/20;
j = (temp-i*20)/5;
shuibi = temp + 5*i+j;
}else{
System.out.print("请输入正确的携带钱数!!!");
}
return shuibi;
}
}