【发布时间】:2020-04-08 10:03:26
【问题描述】:
问题陈述:SRV 学院希望认可本学年成功获得最多实习机会的院系。参与招聘的部门有CSE、ECE、MECH。帮助学院找到获得最大展示位置的部门。检查示例快照中给出的所有可能输出
注意:如果任何输入为负,则输出应为“输入无效”。如果所有部门的职位数量相同,则输出应为“没有一个部门获得最高职位”。
示例输入 1:
Enter the no of students placed in CSE:90
Enter the no of students placed in ECE:45
Enter the no of students placed in MECH:70
Sample Output 1:
Highest placement
CSE
示例输入 2:
Enter the no of students placed in CSE:55
Enter the no of students placed in ECE:85
Enter the no of students placed in MECH:85
Sample Output 2:
Highest placement
ECE
MECH
示例输入 3:
Enter the no of students placed in CSE:0
Enter the no of students placed in ECE:0
Enter the no of students placed in MECH:0
Sample Output 3:
None of the department has got the highest placement
示例输入 4:
Enter the no of students placed in CSE:10
Enter the no of students placed in ECE:-50
Enter the no of students placed in MECH:40
Sample Output 3:
Input is Invalid
我能够提出一个基本上通过所有可见条件的代码,但未能测试一个。不太确定我哪里出错了。
我完全同意下面的代码效率不高
import java.util.*;
class Placement{
public static void main(String[] args) {
int x,y ,z ;
scanner sc= new Scanner(System.in) ;
System.out.printIn( "Enter the no of students placed in CSE: " );
x=sc.nextInt( );
System.out.printIn("Enter the no of students placed in ECE:" );
y=sc.nextInt( ) ;
System.out.println("Enter the no of students placed in MECH:" );
z=sc.nextInt( ) ;
if(x==z && x==y && y==z){
System.out.printIn("None of the department has got the highest placement" ) ;
}
else if(x<0 || y<0 || z<0){
System.out.printIn("Input is Invalid" ) ;
}
else{
System.out.println( "Highest placement" );
if(x>=z && x>=z){
if(x==y){
System.out.printIn( "CSE" );
System.out.printIn("ISE" );
}
else if(x==z) {
System.out.printIn("CSE" ) ;
System.out.printIn( "MECH" ) ;
}
else{
System.out.println("CSE" );
}
}
else if(y>=z){
{
if(y==z){
System.out.printIn( "ECE" );
System.out.printIn( "MECH" ) ;
}
else{
System.out.println("ECE" ) ;
}
else{
System.out.printIn( "MECH" ) ;
}
}
}
输出:
Proposed grade: 85. 71 / 100
Result Description
Failed tests
Test 2: CheckConditionsForTwoMax
Test 1: Check Conditions
Summary of tests
*Note: All the test cases might not have same weightage
7 tests run/ 6 tests passed
【问题讨论】:
-
请在问题本身中包含所有代码和输出
-
问题是我正在编码的平台不允许我复制或粘贴代码
-
@Cruncher 我已经通过取出图像添加了代码。财政年度
-
抱歉,我通过添加代码图像让问题不清楚,我能够从图像中提取文本并添加代码 sn-p 以及获得的输出。
-
您发布的代码将无法编译:它有
System.out.printIn(最后一个字符之前是大写i,而不是小写L)。在单个if语句之后还有 2 个else块。
标签: java data-structures