SDUT JAVA lab3.1

简介: SDUT JAVA lab3.1

7-1 sdut-JAVA- The total cost

分数 17

 

全屏浏览

作者 马新娟

单位 山东理工大学

CSIS Radio offers each winner of a competition the choice of 2 books from one of three categories. The management has requested you to write a Java program that will allow them to enter the category chosen by a winner and your program will calculate the total cost of sending the books to this winner. The total cost comprises the cost of the books chosen as well as an additional cost of €10 for postage and packaging. If a book category other than those shown in the following table is entered, your program should display an “Invalid book category: 1, 2 and 3 are valid categories.” message.

 

Input Specification:

Enter category selected by winner.

Output Specification:

the total cost of sending the books to this winner. If a book category other than those shown in the following table is entered, your program should display an “Invalid book category: 1, 2 and 3 are valid categories.” message.

Sample Input:

1

Sample Output:

Cost of prize = 75.0

代码长度限制

16 KB

时间限制

400 ms

内存限制

64 MB

栈限制

8192 KB

import java.util.Scanner;
public class Main
{   public static void main(String [] args)
  {
    Scanner in =new Scanner(System.in);
    int n;
    n=in.nextInt();
    if(n==1||n==2||n==3)
    {
      if(n==1)
      { 
    
        System.out.println("Cost of prize = "+75.0);
      }
      else if(n==2)
      {
        
        System.out.println("Cost of prize = "+(30*2+10));
      }
      else if(n==3)
      {
        System.out.println("Cost of prize = "+(25.75*2+10));
      }
    }
    else{
      System.out.println("Invalid book category: 1, 2 and 3 are valid categories.");
    }
  }
}

 

 

 


目录
相关文章
|
4月前
|
Java
SDUT java lab 7.3
SDUT java lab 7.3
24 0
|
4月前
|
Java
sdut java lab 7.1(法二好理解)
sdut java lab 7.1(法二好理解)
50 1
|
4月前
|
Java 应用服务中间件 AHAS
sdut java lab6主观题
sdut java lab6主观题
30 0
|
4月前
|
人工智能 Java
sdut java lab5
sdut java lab5
32 0
|
4月前
|
Java
sdut java lab7.2(法二)
sdut java lab7.2(法二)
39 0
|
4月前
|
存储 Java
SDUT java lab7.4
SDUT java lab7.4
28 0
|
4月前
|
Java
SDUT JAVA lab3.9
SDUT JAVA lab3.9
39 2
|
4月前
|
Java
SDUT Java lab6
SDUT Java lab6
22 0
|
4月前
|
Java
sdut java lab7单选
sdut java lab7单选
34 0
|
4月前
|
存储 Java 索引
sdut java lab 7.6
sdut java lab 7.6
35 0