In the name of ALLAH, the Most Beneficent, the Most Merciful

Cs506 Assignment 1 Solution Spring 2024 || Cs506 Assignment 1 Solution 2024

Cs506 Assignment 1 Solution Spring 2024 || Cs506 Assignment 1 Solution 2024

        

Cs506 Assignment 1 Solution Spring 2024 || Cs506 Assignment 1 Solution 2024





Are you looking for Cs506 Assignment 1 Solution Spring 2024?  Then Your Landing on the Right Place . This Website is for Assignment Quiz and Gdbs of Virtual University of Pakistan. This   is an idea solution of assignment .Please Make Some changes in assignment otherwise we are not responsible for Zero marks.


If u Need Paid Solution of


Cs506  Assignment 1,


 

Then WhatsApp me   03086278790

 

 

Introduction of Virtual University of Pakistan

Virtual University is Online University of Pakistan. Its first Online University in Pakistan. All The Activities of university is online that Students easily can Attempt. In this university online Education is easy and Affordable for everyone. Its Provide quality of Education in Pakistan and Overseas too.

 

Important Instruction to submit Assignment

 

1-   Please Take Idea From this Solution an Then Make Your Own Solution

1-  Before Submitting Assignments please Check Assignments Instruction.

3-   Please Check that Assignment is in Proper Format Like docx And Zip.

4-  If U submit Same Solution then You Will Get Zero Marks.

5-  Please check All Things in Assignments is Correct.

6-   If There Is Any Mistake In Assignment Please Comment below.

7-   Please do Not Copy Past Assignments Solution.


Join WhatsApp Group


 

Cs506 Assignment 1 Solution Spring 2024


Code

 

import javax.swing.JOptionPane;
import java.util.ArrayList;

public class Marathon {

    public static void main(String[] args) {
        new Marathon().init();
    }

    private void init() {
        int participantCount = getParticipantCount();
        ArrayList<Runner> runners = new ArrayList<>();

        for (int i = 0; i < participantCount; i++) {
            runners.add(getRunnerDetails());
        }

        Runner fastestRunner = findFastestRunner(runners);
        displayResult(fastestRunner);
        displayStudentId();
    }

    private int getParticipantCount() {
        int participants;
        do {
            String input = JOptionPane.showInputDialog(null, "Enter the number of participants (positive number):");
            try {
                participants = Integer.parseInt(input);
                if (participants <= 0) {
                    JOptionPane.showMessageDialog(null, "Invalid number of participants. Please enter a positive number.");
                }
            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(null, "Invalid input. Please enter a number.");
                participants = -1;
            }
        } while (participants <= 0);
        return participants;
    }

    private Runner getRunnerDetails() {
        String name;
        int time;
        do {
            name = JOptionPane.showInputDialog(null, "Enter runner's name:");
            if (name == null || name.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Name cannot be empty. Please enter a name.");
            }
        } while (name == null || name.isEmpty());

        do {
            String input = JOptionPane.showInputDialog(null, "Enter runner's finishing time in minutes (positive number):");
            try {
                time = Integer.parseInt(input);
                if (time <= 0) {
                    JOptionPane.showMessageDialog(null, "Invalid finishing time. Please enter a positive number.");
                }
            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(null, "Invalid input. Please enter a number.");
                time = -1;
            }
        } while (time <= 0);
        return new Runner(name, time);
    }

    private Runner findFastestRunner(ArrayList<Runner> runners) {
        Runner fastest = runners.get(0);
        for (Runner runner : runners) {
            if (runner.getTime() < fastest.getTime()) {
                fastest = runner;
            }
        }
        return fastest;
    }

    private void displayResult(Runner fastestRunner) {
        String message = "The fastest runner is " + fastestRunner.getName() + " with a finishing time of " + fastestRunner.getTime() + " minutes.";
        JOptionPane.showMessageDialog(null, message);
    }

    private void displayStudentId() {
        JOptionPane.showMessageDialog(null, "VU Student Id: (Vucopier"); // Replace with your VU Student Id
    }

    private class Runner {
        private String name;
        private int time;

        public Runner(String name, int time) {
            this.name = name;
            this.time = time;
        }

        public String getName() {
            return name;
        }

        public int getTime() {
            return time;
        }
    }
}





If u Need Paid and Unique Solution of

Cs506 Assignment 1 


 

Then WhatsApp me  

03086278790

 

Cs506 Assignment 1 Solution Spring 2024 || Cs506 Assignment 1 Solution 2024




 

 


Final term Past Paper

 

 

 MEGA Files

 

Download Now

 

FINAL TERM PAST PAPER BY WAQAR SINDHU

 

Download Now

 

FINAL TERM PAST PAPER BY MOAAZ

 

Download Now

 

 

Cs506 Assignment 1 Solution Spring 2024 || Cs506 Assignment 1 Solution

Cs506 Assignment 1 Solution Spring 2024 ||Cs506 Assignment 1 Solution

 

tags

Cs506 Assignment 1 Solution Spring 2024,Cs506 assignment solution 2024, Cs506 assignment solution Spring 2024, Cs506 assignment solution 2024,Cs506 Assignment, Cs304 Assignment 1, Cs506 Assignment 1 Solution,Cs506 Assignment No 1  Solution Spring 2024,Cs506 Assignment 1 Solution 20224 File, Cs506 Correct Assignment Solution 2024, Cs304  Assignment 2024 Solution, Cs506  Assignment 2024 100% Correct Solution.




Post a Comment (0)
Previous Post Next Post
z
//1