Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you rewrite this Java code in the Swift programming language? 1 import java.

ID: 3878505 • Letter: C

Question

Can you rewrite this Java code in the Swift programming language?

1 import java.util.Scanner; 2 public class Grader 4. public static void main (String [] args) 6 7 8 9 10 nt score; char grade; System.out.println ("Enter your score:"); Scanner keyboard new Scanner (System.in); score keyboard.nextInt(; if (score >= 90) 12 13 14 15 16 17 18 19 20 21 else if (score = 8 else if (score >= 70) else if (score = else grade'A' grade = 'B' grade "C. grade = 'D' grade = 'F': 60 System.out.println ("Score"score); System.out.println ("Grade"+ grade); 23 24

Explanation / Answer

print("Enter your score : ")
let num1 = readLine()

var score = Int(num1!) // convert string to integer

var grade = " "

if score! >= 90
{
grade = "A"
}
else if score! >= 80
{
grade = "B"
}
else if score! >= 70
{
grade = "C"
}
else if score! >= 60
{
grade = "D"
}
else
{
grade = "F"
}
print("Score = ",score!)
print("Grade = ",grade)

Output:

Enter your score :78
Score = 78
Grade = C

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote