7-3 sdut-JAVA-Cost Of Photo copying
分数 11
全屏浏览
切换布局
作者 马新娟
单位 山东理工大学
A copying centre charges 5c per copy for the first 100 copies and 3c per copy for each additional copy. Write a program that requests the number of copies as input and displays the total cost.
Input Specification:
the number of copies as input.
Output Specification:
displays the total cost.
Sample Input:
89
Sample Output:
Cost of 89 copy/copies is 4.45
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
栈限制
8192 KB
import java.util.Scanner; public class Main{ public static void main(String [] args) { Scanner sc=new Scanner(System.in); int n; n=sc.nextInt(); double t=0; if(n<=100&&n>=0) { t=n*0.05; System.out.println("Cost of "+n+" copy/copies is "+t); } else { t=0.05*100+(n-100)*0.03; System.out.println("Cost of "+n+" copy/copies is "+t); } } }