SDUT JAVA Lab3.6

简介: 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.

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");
    }
  }
}


目录
相关文章
|
8月前
|
Java
SDUT java lab 7.3
SDUT java lab 7.3
28 0
|
8月前
|
Java
sdut java lab 7.1(法二好理解)
sdut java lab 7.1(法二好理解)
67 1
|
8月前
|
Java 应用服务中间件 AHAS
sdut java lab6主观题
sdut java lab6主观题
43 0
|
8月前
|
人工智能 Java
sdut java lab5
sdut java lab5
44 0
|
8月前
|
Java
sdut java lab7.2(法二)
sdut java lab7.2(法二)
53 0
|
8月前
|
存储 Java
SDUT java lab7.4
SDUT java lab7.4
44 0
|
8月前
|
Java
SDUT JAVA lab3.9
SDUT JAVA lab3.9
54 2
|
8月前
|
Java
SDUT Java lab6
SDUT Java lab6
34 0
|
8月前
|
Java
sdut java lab7单选
sdut java lab7单选
51 0
|
8月前
|
存储 Java 索引
sdut java lab 7.6
sdut java lab 7.6
55 0