Tillämpade Övningar 1 The main focus in this part is on the following concepts: Loops (Task 1-4) and Arrays(Task 5, 6). In all tasks make sure that you apply exception handling, when needed. For...

1 answer below »
Hello i want this task to be solved done asap please and well commented.


Tillämpade Övningar 1 The main focus in this part is on the following concepts: Loops (Task 1-4) and Arrays(Task 5, 6). In all tasks make sure that you apply exception handling, when needed. For example, when reading an integer from keyboard or dividing by a number. Task 1 A special lottery consists of a ring with tickets that are (invisibly) numbered with 2, 4, 6, 8, 10, 12,…, 100. The drawn number determines the price of the ticket! If you draw the lottery with number 26, in other words that particular lottery ticket costs SEK 26. Write a program that summarizes and prints how much income you get if you sell all the tickets in the ring. Algorithm: Task 2 Write a program that, using a loop, calculate the product of all integers between 1 and N (the entered number). If you read 20 from the console window, the program should therefore calculate and show the result of 1 × 2 × 3 × 4 ×… × 20. Task 3 The application shall ask the user to input an integer, take the integer and save it in a variable called radius, and then compute the volume of spheres with their radius from 1 to the input value. Write a separate method to do the calculation and call your method from the Main method. For example if the input value is 10, the output shall display sphere’s volume with radius from 1 to 10, like this: “Sphere’s volume with radius 1 is ……” “Sphere’s volume with radius 2 is ……” ………….. “Sphere’s volume with radius 10 is ……” Sphere’s volume = Task 4 Write an application that prompts a student to enter his/her grade (‘A’ to ‘F’) on a course and displays the grade’s definition in the output screen (Based on the following ECTS Definitions). The student should be able to enter a grade many times until ‘G’ is entered to end the program. ECTS Definition A Excellent – outstanding performance with only minor errors B Very good – above the average standard but with some errors C Good– generally sound work with a number of notable errors D Satisfactory – fair but with significant shortcomings E Sufficient – performance meets the minimum criteria Fx Fail – some more work required before the credit can be awarded F Fail - considerable further work is required Hint: use a switch-statement embedded in a while-statement. Task 5 Develop a Console application that displays ten student grades together with a histogram. Use an array to hold the grades. Use the random class to generate the grades. Note: No user input is needed. The grades shall be created randomly. No need to create any additional method. Everything can be done in Main method. The output may look like: Task 6 Your program contains an array with ten random numbers between 0 and 19. Write methods accordingly to the specification below. Make sure your methods work correctly by testing them. Testing your methods is always easier if you know what the output should be, given a specific input. A suggestion is to work with pen and paper first to figure out what the output should be. a) Write a method that takes an array as parameter and returns the index of the smallest number in the array. b) Write a method that takes an array as parameter and returns the index of the largest number in the array. c) Write a method that switch position of two numbers in the array. The method shall have two input parameters, the indexes of the numbers to switch.
Answered Same DayNov 11, 2021

Answer To: Tillämpade Övningar 1 The main focus in this part is on the following concepts: Loops (Task 1-4) and...

Neha answered on Nov 12 2021
133 Votes
Practice/.idea/.gitignore
# Default ignored files
/shelf/
/workspace.xml
Practice/.idea/description.html
Simple Java application that includes a class with main() method
Practice/.idea/encodings.xml




Practice/.idea/misc.xml










Practice/.idea/modules.xml






Practice/.idea/project-template.xml

IJ_BASE_PACKAGE
Practice/.idea/workspace.xml




















































































1604250867614


1604250867614









































file://$PROJECT_DIR$/src/Task1.java
10





Practice/Practice.iml









Practice/out/production/Practice/Main.class
public synchronized class Main {
public void Main();
private static int getMin(int[]);
private static int getMax(int[]);
private static void swapElements(int[], int, int);
private static void printElem(int[]);
public static void main(String[]);
}
Practice/out/production/Practice/Task1.class
public synchronized class Task1 {
public void Task1();
private static void computeLottery();
public static void main(String[]);
}
Practice/out/production/Practice/Task2.class
public synchronized class Task2 {
public void Task2();
private static long getFactorial(int);
public static void main(String[]);
}
Practice/out/production/Practice/Task3.class
public synchronized class Task3 {
public void Task3();
private static double getVol(double);
private static void compute(int);
public static void main(String[]);
}
Practice/out/production/Practice/Task4.class
public synchronized class Task4 {
private static String A;
private static String B;
private static String C;
private static String D;
private static String E;
private static String Fx;
private static String F;
public void Task4();
private static void printError();
private static void inputGrade();
public static void main(String[]);
static void ();
}
Practice/out/production/Practice/Task5.class
public synchronized class Task5 {
public void Task5();
private static void printAsterisk(int);
private static void printLine(int, int);
public static void main(String[]);
}
Practice/out/production/Practice/Task6.class
public synchronized class Task6 {
public void Task6();
private static int getMin(int[]);
private static int getMax(int[]);
private static void swapElements(int[], int, int);
private static void printElem(int[]);
public static void...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here