i have an assignment saying :
The character part of the course code (the first 3 characters of the course code), e.g. (csc), need to be changed to capital letters.
You should stores the student level which is correspondence to the first digit of the course code from the right hand side, e.g. if the course code is CSC224, this student is at level 4.
You should calculate the remaining number of terms for the student to graduate based on the current level, assuming that the last level is level 10.
i could do the first two points, but i'm stock in the third. i know that i cant do operations between a String and an Int, so i have to convert the str to an int. but that didnt work for me, i dont know why?!.
import java.util.*;
public class HighSpecialCourseCode
{
static Scanner input = new Scanner (System.in);
public static void main (String[] args)
{
// declaring
String CourseCode;
String Level ;
// input
System.out.println("Course code:");
CourseCode=input.next().toUpperCase();
System.out.println("\nCourse Code: "+ CourseCode);
// output
Level=CourseCode.substring(CourseCode.length()-1);
System.out.println("Student Level: "+ Level);
int RemainingTerms = Integer.parseInt("Level");
System.out.print("Remaining Terms: " + (10 - Level) );
}
}
this is my code and when i compile it, i get :
HighSpecialCourseCode.java:25: error: bad operand types for binary operator '-'
System.out.print("Remaining Terms: "+ (10 - Level) );
^
first type: int
second type: String
1 error
i already converted ( Level ) so why isn't working!!