SDUT JAVA Lab3.6

7-6 sdut- JAVA-Overall Project Cost

分数 12

全屏浏览

切换布局

作者 马新娟

单位 山东理工大学

You are required to write a Java application program to determine and display the overall cost of a project. The overall cost of a project is made up of a fixed cost and a variable cost. Each project has a fixed cost of €10,000 and depending on the project category and the service type a variable cost is added. To determine the variable cost of a project, your program should accept a project category and a service type from the end user and depending on their values, determine the variable cost of the project based on the data in Table 1. A valid project category is one of 1, 2 or 3. If the user does not supply a valid project category an appropriate error message should be displayed and your program should end. The appropriate error message should be “Invalid project category: project category should be in the range 1 to 3“. If the user supplies a valid project category he/she should then be requested to enter a key service type. A valid service type is one of 1, 2 or 3. If the user supplies and invalid key service type an appropriate error message should be displayed and your program should end. The appropriate error message should be “Invalid service type: service type should be in the range 1 to 3“ If a valid service type is supplied then your program should determine the overall cost and display it.

截图20230325192503.png

Input Specification:

the project category and the service type .

Output Specification:

display the overall cost of a project.

Sample Input:

2
3

Sample Output:

Project cost is: 23500.0

代码长度限制

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);
		double[][] a = {{5600.50, 5500.00, 6000.00}, 
                        {10600.50, 11000.00, 13500.00}, 
                        {17000.00, 22000.00, 25000.00}};
       
	    int n;int t;
		n=sc.nextInt();
		if(n==1||n==2||n==3)
		{
			t=sc.nextInt();
			if(t==1||t==2||t==3)
			{
				System.out.println("Project cost is: "+(a[n-1][t-1]+10000));
			}
			else{
				System.out.println("Invalid service type: service type should be in the range 1 to 3");
			}
		}
		else
		{
			System.out.println("Invalid project category: project category should be in the range 1 to 3");
		}
	}
}

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值