import java.util.Scanner;
//饮料换购–1
public class Test08 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(“请输入买了多少瓶饮料:”);
int count = sc.nextInt();
int bottleCap = 0; //记录瓶盖数量
for (int i = 0; i < count; i++) {
//模拟喝了一瓶,得到一个盖子
bottleCap++;
if (bottleCap % 3 == 0) { //如果盖子数量到了3可以直接换一瓶饮料
//换了一瓶饮料,盖子数量变为0,饮料数量+1
bottleCap = 0;
count++;
}
}
System.out.println(“总共可以喝到” + count + “瓶饮料”);
}
}