1 条题解
-
0
C :
#include<stdio.h> int main() { double N,X; scanf("%lf",&N); if(N<=2000) { printf("Isento"); } else if(N>2000&&N<=3000) { X=(N-2000)*0.08; printf("R$ %.2lf",X); } else if(N>3000&&N<=4500) { X=1000*0.08+(N-3000)*0.18; printf("R$ %.2lf",X); } else { X=1000*0.08+1500*0.18+(N-4500)*0.28; printf("R$ %.2lf",X); } return 0; }C++ :
#include<cstdio> using namespace std; int main() { double a; scanf("%lf",&a); if(a<=2000.00) printf("Isento"); if(a>2000.00&&a<=3000.00) printf("R$ %.2lf",(a-2000.00)*0.08); if(a>3000.00&&a<=4500.00) printf("R$ %.2lf",80+(a-3000.00)*0.18); if(a>4500.00) printf("R$ %.2lf",350+(a-4500.00)*0.28); return 0; }Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { double second = 0; double third = 0; double more = 0; Scanner scanner = new Scanner(System.in); double wage = scanner.nextDouble(); if (wage >= 0.00 && wage <= 5000) { if (wage >= 2000.01 && wage <= 3000.00) { second = (wage - 2000.00) * 0.08; double all = second + third + more; System.out.println("R$ " + String.format("%.2f", all)); } else if (wage >= 3000.01 && wage <= 4500.00) { second = 1000 * 0.08; third = (wage - 3000.00) * 0.18; double all = second + third + more; System.out.println("R$ " + String.format("%.2f", all)); } else if (wage > 4500.00) { second = 1000 * 0.08; third = 1500 * 0.18; more = (wage - 4500.00) * 0.28; double all = second + third + more; System.out.println("R$ " + String.format("%.2f", all)); } else { System.out.println("Isento"); } } } }
- 1
信息
- ID
- 649
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 提交数
- 94
- 已通过
- 28
- 上传者