Questions
2. Write a program in C++ that: a) Declares a 1D array A with 30 elements...

2. Write a program in C++ that:

a) Declares a 1D array A with 30 elements

b) Inputs an integer n from 1-30 from the keyboard. If n < 1 set n = 1. If n > 30 set n = 30.

the program should keep asking the user the input n one by one, followed by printing of the value of n (n=n if bigger than 1 and smaller than 30, 1 if smaller than 1 and 30 if bigger than 30)

In: Computer Science

Why is it dangerous to acquire a lock in an interrupt handler?

Why is it dangerous to acquire a lock in an interrupt handler?

In: Computer Science

How to use python to find all longest common subsequences of 2 sequences? In addition, please...

How to use python to find all longest common subsequences of 2 sequences? In addition, please also analyze the space complexity.

For example, the input is "ABCBDAB" and "BDCABA", then the lcs should be "BCAB" "BDAB" and "BCBA".

In: Computer Science

c++ We can dynamically resize vectors so that they may grow and shrink. While this is...

c++

We can dynamically resize vectors so that they may grow and shrink. While this is very

convenient, it is inefficient. It is best to know the number of elements that you need for your vector

when you create it. However, you might come across a situation someday where you do not know

the number of elements in advance and need to implement a dynamic vector.

Rewrite the following program so that the user can enter any number of purchases, instead of just

10 purchases. Output the total of all purchases. Hint: us do while loop with your vector..

#include

#include

using namespace std;

int main()

{

vector purchases(10);

for (int i = 0; i < 10; i++)

{

cout << "Enter a purchase amount";

cin >> purchases[i];

}

return (0);

}

Write your code here:

Use the Snipping Tool to show output

In: Computer Science

C++ Define a class PersonalRecord, which will be storing an employee’s information. Internally, the class should...

C++

Define a class PersonalRecord, which will be storing an employee’s information.


Internally, the class should have the following attributes:

SSN (string type), fullName (string type), homeAddress (string type), phoneNumber (string type), salaryRate (per year, float type), and vacationDays (accrued vacation, int type).


The constructor should take six parameters:

four of them are necessary to provide values to at the time of initialization (when a constructor will be called/invoked): SSN, fullName, homeAddress, and phoneNumber;

and two of them are optional parameters: salaryRate, vacationDays with values by default to be 0 for each.


Provide natural implementation for the member functions:

getName(), setName(name), getSalary(), and setSalary(salary).


Use the header file (.h) and the source-code file (.cpp) to separate the interface of the class from its implementation.


You don’t need to incorporate any checks on validity of data.


The test code given below creates two records for the following people (if you want to use it for testing, put in into a separate .cpp file):

John Hue; SSN: 111119911; Address: 234 Avenue B, Brooklyn, NY; phone number: (718) 222-3445; salary: $35000.

Mary Jones; SSN: 222334455; Address: 123 Kings Avenue, Apt. 10, Queens, NY; phone

number: (718) 555-3112.

Then calls some of the methods to see that they are working.


Feel free to use a C++ code editor. When putting the answer below, first put the content of the header file, followed with

//--------------- implementation

comment, then put the content of the source-code file.

Test code:

#include <iostream>

#include "PersonalRecord.h"
using namespace std;


int main() {

  PersonalRecord p1("111119911", "John Hue", "234 Avenue B, Brooklyn, NY", "(718)222-3445", 35000);

  cout << p1.getName() << " earns $" << p1.getSalary() << " per year\n";

  PersonalRecord p2("222334455", "Mary Jones", "123 Kings Avenue, Apt. 10, Queens, NY", "(718)555-3112");

  cout << p2.getName() << " earns $" << p2.getSalary() << " per year\n"; cout << " after the information is updated: " << endl;

p2.setName("Mary A Jones");

p2.setSalary(50000);

cout << p2.getName() << " earns $" << p2.getSalary() << " per year\n";

}

In: Computer Science

Given the following series: 1, 2, 5, 26, 677, ….. such that the nth term of...

Given the following series: 1, 2, 5, 26, 677, ….. such that the nth term of the series equals to (n-1)th ^2 +1 and the first term of the series is 1. Write a C program using recursive function named f to compute the nth term. Use for loop to print the values of first n terms in the series. You will take input n from the user.

Example output:

Enter number of terms: *value*

*numbers here*

nth term: *value*

PLEASE DO NOT USE IOSTREAM

In: Computer Science

In Java please: 1) Part 1: Edit the getTileList method (add length method too) Dear Developer,...

In Java please:

1) Part 1: Edit the getTileList method (add length method too)


Dear Developer, It seems an overzealous programmer tried to create a Fibonacci slider puzzle from our old code. This brought up the fact there is a data integrity issue in our SlidingSquarePuzzle class. It makes sense because the class’s data only consists of an int[]. Since, you are new this is a good opportunity to get your feet wet. I want you to change the offending code and help shore up our security hole. I’ve attached their Driver and the GUI and SlidingSquarePuzzle files. I’ve also commented out the offending code. Sincerely, Your Boss P.S. You might as well include some documentation while you’re at it. It’s been bugging me for the longest time.

Part 1: Edit the getTileList method

1. Why does this method create a security issue? a. Because you have direct access to the array. As seen in the driver, you have the reference to the array.

2. Change the method to getTile(int index) and return an int at the specific index of tileList.

3. This will break the GUI code. You will need to replace instances of getTileList with getTile. a. Even though you have changed everything, your code will not work. b. This is due to the return data being primitive. You cannot assign data to a primitive data type.

4. Add a length method that returns the tileList.length. a. Replace where necessary.

=================

Driver.java:

public class Driver {

        public static void main(String[] args) {
                //change this number to how many tiles you want
                int numberOfTiles = 9;
                
                SlidingSquarePuzzle fibonaciSlider = new SlidingSquarePuzzle(numberOfTiles);
                
//              fibonaciSlider.getTileList()[0] = 1;
//              fibonaciSlider.getTileList()[1] = 1;
//              fibonaciSlider.getTileList()[2] = 2;
//              fibonaciSlider.getTileList()[3] = 3;
//              fibonaciSlider.getTileList()[4] = 5;
//              fibonaciSlider.getTileList()[5] = 8;
//              fibonaciSlider.getTileList()[6] = 13;
//              fibonaciSlider.getTileList()[7] = 21;
                
                GUI.init(fibonaciSlider);
        }

}

=====================

GUI.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
@SuppressWarnings("serial")
public class GUI extends JPanel {
 
    private SlidingSquarePuzzle ssp;
    private final int sideLength;
    private final int tileSize;
    private int blankPos;
    private final int margin;
    private final int gridSize;
    private boolean gameOver;
 
    private GUI(SlidingSquarePuzzle ssp) {
        this.ssp = ssp;
                sideLength = (int) Math.floor(Math.sqrt(ssp.getTileList().length));
        final int resolution = 640;
        margin = 40;
        tileSize = (resolution - 2 * margin) / sideLength;
        gridSize = tileSize * sideLength;
 
        setPreferredSize(new Dimension(resolution, resolution + margin));
        setBackground(Color.WHITE);
        setForeground(new Color(0x006940)); 
        setFont(new Font("SansSerif", Font.BOLD, 60));
 
        gameOver = true;
        
        addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                if (gameOver) {
                        newGame();
                } else {
 
                    int ex = e.getX() - margin;
                    int ey = e.getY() - margin;
                    if (ex < 0 || ex > gridSize || ey < 0 || ey > gridSize) return;
 
                    int clickX = ex / tileSize;
                    int clickY = ey / tileSize;
                    int blankX = blankPos % sideLength;
                    int blankY = blankPos / sideLength;
 
                    int clickPos = clickY * sideLength + clickX;
 
                    int direction = 0;
                    if (clickX == blankX && Math.abs(clickY - blankY) > 0) {
                        direction = (clickY - blankY) > 0 ? sideLength : -sideLength;
 
                    } else if (clickY == blankY && Math.abs(clickX - blankX) > 0) {
                        direction = (clickX - blankX) > 0 ? 1 : -1;
                    }
 
                    if (direction != 0) {
                        do {
                            int newBlankPos = blankPos + direction;
                            ssp.getTileList()[blankPos] = ssp.getTileList()[newBlankPos];
                            blankPos = newBlankPos;
                        } while (blankPos != clickPos);
                        ssp.getTileList()[blankPos] = 0;
                    }
 
                    gameOver = ssp.isSolved();
                }
                repaint();
            }
        });
        newGame();
    }
    
    private void newGame() {
        ssp.shuffle();
        gameOver = false;
        for (int i = 0; i < ssp.getTileList().length; i++) {
                if(ssp.getTileList()[i] != 0) continue;
                blankPos = i;
                break;
        }
    }
 
    private void drawGrid(Graphics2D g) {
        for (int i = 0; i < ssp.getTileList().length; i++) {
            int x = margin + (i % sideLength) * tileSize;
            int y = margin + (i / sideLength) * tileSize;
 
            if (ssp.getTileList()[i] == 0) {
                if (gameOver) {
                    g.setColor(Color.GREEN);
                    drawCenteredString(g, "\u2713", x, y);
                }
                continue;
            }
 
            g.setColor(getForeground());
            g.fillRoundRect(x, y, tileSize, tileSize, 25, 25);
            g.setColor(Color.green.darker());
            g.drawRoundRect(x, y, tileSize, tileSize, 25, 25);
            g.setColor(Color.WHITE);
 
            drawCenteredString(g, String.valueOf(ssp.getTileList()[i]), x, y);
        }
    }
 
    private void drawStartMessage(Graphics2D g) {
        if (gameOver) {
            g.setFont(getFont().deriveFont(Font.BOLD, 18));
            g.setColor(getForeground());
            String s = "click to start a new game";
            int x = (getWidth() - g.getFontMetrics().stringWidth(s)) / 2;
            int y = getHeight() - margin;
            g.drawString(s, x, y);
        }
    }
 
    private void drawCenteredString(Graphics2D g, String s, int x, int y) {
        FontMetrics fm = g.getFontMetrics();
        int asc = fm.getAscent();
        int des = fm.getDescent();
 
        x = x + (tileSize - fm.stringWidth(s)) / 2;
        y = y + (asc + (tileSize - (asc + des)) / 2);
 
        g.drawString(s, x, y);
    }
 
    @Override
    public void paintComponent(Graphics gg) {
        super.paintComponent(gg);
        Graphics2D g = (Graphics2D) gg;
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
 
        drawGrid(g);
        drawStartMessage(g);
    }
 
    public static void init(SlidingSquarePuzzle ssp) {
        SwingUtilities.invokeLater(() -> {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setTitle("Slidng Square Puzzle");
            f.setResizable(false);
            f.add(new GUI(ssp), BorderLayout.CENTER);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        });
    }
}

======================

SlidingSquarePuzzle.java

import java.util.Arrays;
import java.util.Random;

public class SlidingSquarePuzzle {
        private int [] tileList;
        
        public SlidingSquarePuzzle() {
                this(16);
        }
        public SlidingSquarePuzzle(int size) {
                tileList = size < 4 
                                ? new int[4]
                                : new int[(int) Math.pow(Math.floor(Math.sqrt(size)), 2)];
                solve();
        }
        public int[] getTileList() {
                return tileList;
        }
        public void solve() {
                for(int i = 0; i < tileList.length - 1; i++) {
                        tileList[i] = i + 1;
                }
        }
        public boolean isSolved() {
                for(int i = 0; i < tileList.length - 1; i++)
                        if (tileList[i] != i + 1) return false;
                return true;
        }
        /*
         * This looks at the puzzle and checks if it is solvable
         */
        private boolean isSolvable()  {
                int inversions = 0;
                int m = (int) Math.floor(Math.sqrt(tileList.length));
                for(int i = 0; i < tileList.length; i++)
                        for(int j = i + 1; j < tileList.length; j++)
                        {
                                if(tileList[i] == 0 || tileList[j] == 0) continue;
                if (tileList[j] < tileList[i])
                    inversions++;
                        }
                if(m % 2 == 1)
                        return inversions % 2 == 0;
                else {
                        int blankIndex = 0; 
                        for(int i = 0; i < tileList.length; i++)
                                if(tileList[i] == 0 ) {
                                        blankIndex = i;
                                        break;
                                }
                        if((blankIndex / m) % 2 == 0)
                                return inversions % 2 == 1;
                        else
                                return inversions % 2 == 0;
                }
        }
        public void shuffle() {
                Random rand = new Random();
                do {
                        for(int i = tileList.length - 1; i > 0; i--) {
                                int j = rand.nextInt(i + 1);
                                int temp = tileList[j];
                                tileList[j] = tileList[i];
                                tileList[i] = temp;
                        }
                }while(!this.isSolvable());
        }

}

In: Computer Science

here i have a dictionary with the words and i have to find the words with...

here i have a dictionary with the words and i have to find the words with the largest size, (i mean word count for eg abdominohysterectomy) which have anagrams , like for example ,loop -> pool. Also , i have to sort them in alphabetical way so what could be the algorithm for that

public class Anagrams {
   private static final int MAX_WORD_LENGTH = 25;
   private static IArray<IVector<String>> theDictionaries =
       new Array<>(MAX_WORD_LENGTH);
   public static void main(String... args) {
       initTheDictionaies();
       process();
   }
   private static void process() {
//start here
       if (isAnagram("pool", "loop")) {                   // REMOVE
           System.out.println("ANAGRAM!");                   // REMOVE

      
//above this
   }
  
   private static boolean isAnagram(String word1, String word2) {
       boolean b = false;
       if (getWordSorted(word1).equals(getWordSorted(word2))) {
           b = true;
       }
       return b;
   }
   private static String getWordSorted(String word) {
       ISortedList<Character> sortedLetters = new SortedList<>();
       StringBuilder sb = new StringBuilder();
       for (int i = 0; i < word.length(); i++) {
           sortedLetters.add(word.charAt(i));
       }
       for (Character c : sortedLetters) {
           sb.append(c);
       }
       String sortedWord = sb.toString();
       return sortedWord;
   }
   private static void initTheDictionaies() {
       String s;
       for (int i = 0; i < theDictionaries.getSize(); i++) {
           theDictionaries.set(i, new Vector<String>());
       }
       try (
           BufferedReader br = new BufferedReader(
               new FileReader("data/pocket.dic")
           )
       ) {
           while ((s = br.readLine()) != null) {
               theDictionaries.get(s.length()).pushBack(s);
           }
       } catch (Exception ex) {
           ex.printStackTrace();
           System.exit(-1);
       }
       for (int i = 0; i < theDictionaries.getSize(); i++) {
           theDictionaries.get(i).shrinkToFit();
       }
   }
}

In: Computer Science

Write a function matrix power(A, n) that computes the power An using Boolean arithmetic and returns...

Write a function matrix power(A, n) that computes the power An using Boolean arithmetic and returns the result. You may assume that A is a 2D list containing only 0s and 1s, A is square (same number of rows and columns), and n is an integer ≥ 1. You should call your previously written matrix multiply boolean function.

Example: Let R = [ [0, 0, 0, 1], [0, 1, 1, 0], [0, 0, 0, 1], [0, 0, 1, 0] ]

Then calling matrix power(R, 2) should return [ [0, 0, 1, 0], [0, 1, 1, 1], [0, 0, 1, 0], [0, 0, 0, 1] ]

In: Computer Science

Hello sir below is my code can you plz explain it line by line in details...

Hello sir below is my code can you plz explain it line by line in details

#include<stdio.h>

#include<stdlib.h>

#include<stdbool.h>

#include<string.h>

#include<time.h>

struct patient {

int id;

int age;

bool annualClaim;

int plan;

char name[30];

char contactNum[15];

char address[50];

};

#define MAX_LENGTH 500

struct patient patients[100];

int patientCount = 0;

struct claim {

int id;

int claimedYear;

int amountClaimed;

int remaininigAmount;

};

struct claim claims[100];

void subscribe()

{

system("cls");

patients[patientCount].id = patientCount + 1;

printf("Enter age: ");

scanf("%d", & patients[patientCount].age);

printf("\n\n%-25sHealth Insurence Plan\n\n", " ");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20s|%-20s|%-20s|\n", " ", "Plan 120(RM)", "Plan 150(RM)", "Plan 200(RM)");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20d|%-20d|%-20d|\n", "Monthly Premium", 120, 150, 200);

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20d|%-20d|%-20d|\n", "Annual Claim Limit", 120000, 150000, 200000);

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20d|%-20d|%-20d|\n", "Lifetime Claim Limit", 600000, 750000, 1000000);

printf("-----------------------------------------------------------------------------------------------\n");

printf("\n\n%-25sAge Group and Health Insurence Plan\n\n", " ");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-25s%-30s\n", "Types of Claim", " ", "Eligibility Amount");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20s|%-20s|%-20s|\n", " ", "Plan 120(RM)", "Plan 150(RM)", "Plan 200(RM)");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20s|%-20s|%-20s|\n", "Room Charges", "120/day", "150/day", "200/day");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20s|%-20s|%-20s|\n", "Intensive Care Unit", "250/day", "400/day", "700/day");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20s|%-20s|%-20s|\n", "Hospital Supplies and Services", " ", " ", " ");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-60s|\n", "Surgical Fees", "As charged Sbject to approval by ZeeMediLife");

printf("-----------------------------------------------------------------------------------------------\n");

printf("|%-30s|%-20s|%-20s|%-20s|\n", "Other Fees", " ", " ", " ");

printf("-----------------------------------------------------------------------------------------------\n\n");

int ch;

do {

printf("Select a Claim Limit Type\n1-Annual Claim Limit 2-Lifetime Claim Limit: ");

scanf("%d", & ch);

} while (ch < 1 || ch > 2);

if (ch == 1)

patients[patientCount].annualClaim = true;

else

patients[patientCount].annualClaim = false;

do {

printf("Select a plan\n1-Plan120 2-Plan150 3-Plan200: ");

scanf("%d", & ch);

} while (ch < 1 || ch > 3);

patients[patientCount].plan = ch;

printf("Enter Name: ");

scanf("%s", & patients[patientCount].name);

printf("Contact Number: ");

scanf("%s", & patients[patientCount].contactNum);

printf("Enter Address: ");

scanf("%s", & patients[patientCount].address);

FILE * fp;

fp = fopen("patients.txt", "a");

fprintf(fp, "%d,%s,%d,%d,%d,%s,%s\n", patients[patientCount].id, patients[patientCount].name, patients[patientCount].age, patients[patientCount].annualClaim, patients[patientCount].plan, patients[patientCount].contactNum, patients[patientCount].address);

fclose(fp);

time_t s;

struct tm * currentTime;

s = time(NULL);

currentTime = localtime( & s);

claims[patientCount].id = patients[patientCount].id;

claims[patientCount].amountClaimed = 0;

claims[patientCount].claimedYear = currentTime -> tm_hour + 1900;

if (patients[patientCount].annualClaim == true)

{

if (patients[patientCount].plan == 1)

claims[patientCount].remaininigAmount = 120000;

else if (patients[patientCount].plan == 2)

claims[patientCount].remaininigAmount = 150000;

else

claims[patientCount].remaininigAmount = 200000;

} else

{

if (patients[patientCount].plan == 1)

claims[patientCount].remaininigAmount = 600000;

else if (patients[patientCount].plan == 2)

claims[patientCount].remaininigAmount = 750000;

else

claims[patientCount].remaininigAmount = 1000000;

}

patientCount++;

fp = fopen("claims.txt", "a");

if (fp == NULL)

printf("File Dont exist");

fprintf(fp, "%d,%d,%d,%d\n", claims[patientCount].id, claims[patientCount].claimedYear, claims[patientCount].amountClaimed, claims[patientCount].remaininigAmount);

fclose(fp);

system("pause");

}

In: Computer Science

Part A: Write a set of statements that declare a variable of type double called yourNum,...

Part A: Write a set of statements that declare a variable of type double called yourNum, then prompts the user to input a value which gets stored into that variable.

Part B: Write a set of statements that displays the phrase "Even Number!" when the value in the variable count is an even number but displays the phrase “That is odd” otherwise. Declare and initialize all variables.

Part C: Write the necessary code to swap (exchange) the values in two integer variables named oprahsIncome and myIncome . Declare and initialize all variables. You may declare and use only one additional variable.

Write in c language please !!!

In: Computer Science

Give the line numbers executed once power is applied, assuming the switch is released(it starts from...

Give the line numbers executed once power is applied, assuming the switch is released(it starts from the state: STATE_WAIT_FOR_PRESS)
Keep writing numbers until you get a repeating pattern. It will start from line 11, which is the top of the while(1) loop

Also describe what the LED does while the SW1 is repeatedly pressed and released. (specify the case when it blinks)

In: Computer Science

1)Consider a file system in which a file can be deleted and its disk space reclaimed...

1)Consider a file system in which a file can be deleted and its disk space reclaimed while links to that file still exist. What problems may occur if a new file is created in the same storage area or with the same absolute path name? How can these problems be avoided?

2)Consider a file systemthat uses a modified contiguous-allocation scheme with support for extents.A file is a collection of extents, with each extent corresponding to a contiguous set of blocks. A key issue in such systems is the degree of variability in the size of the extents. What are the advantages and disadvantages of the following schemes? a. All extents are of the same size, and the size is predetermined. b. Extents can be of any size and are allocated dynamically. c. Extents can be of a few fixed sizes, and these sizes are predetermined.

3)If all the access rights to an object are deleted, the object can no longer be accessed. At this point the object should also be deleted, and the space it occupies should be returned to the system. Suggest an efficient implementation of this scheme

4)What commonly used computer programs are prone to man-in-the-middle attacks? Discuss solutions for preventing this form of attack.

5)Discuss the following with neat diagrama.

Virtualization and its types

b.Hypervisor

(Operating system ,Computer Science)

In: Computer Science

Hello sir can you explain me this code in details. void claimProcess() { int id; bool...

Hello sir can you explain me this code in details.

void claimProcess()

{

int id;

bool found = false;

system("cls");

printf("Enter patient ID for which you want to claim insurrence: ");

scanf("%d", & id);

int i;

for (i = 0; i < patientCount; i++)

{

if (patients[i].id == id)

{

found = true;

break;

}

}

if (found == false)

{

printf("subscriber not found\n");

return;

}

int numOfDaysHospitalized, suppliesCost, surgicalFee, otherCharges;

bool ICU;

printf("How many days were you haspitalized: ");

scanf("%d", & numOfDaysHospitalized);

int ICUFlag;

do {

printf("Select A Ward Type\n1-Normal Ward 2-ICU: ");

scanf("%d", & ICUFlag);

} while (ICUFlag < 1 || ICUFlag > 2);

if (ICUFlag == 2)

ICU = true;

else

ICU = false;

printf("Enter Cost of Supplies and Services: ");

scanf("%d", & suppliesCost);

printf("Enter Surgical Fees: ");

scanf("%d", & surgicalFee);

printf("Enter Other Charges: ");

scanf("%d", & otherCharges);

int ICUCharges = 0;

if (ICU == true)

{

if (patients[i].plan == 1)

ICUCharges = numOfDaysHospitalized * 120;

else if (patients[i].plan == 2)

ICUCharges = numOfDaysHospitalized * 150;

else

ICUCharges = numOfDaysHospitalized * 200;

} else

{

if (patients[i].plan == 1)

ICUCharges = numOfDaysHospitalized * 250;

else if (patients[i].plan == 2)

ICUCharges = numOfDaysHospitalized * 400;

else

ICUCharges = numOfDaysHospitalized * 700;

}

int totalClaimAmount = numOfDaysHospitalized + suppliesCost + surgicalFee + otherCharges + ICUCharges;

if (patients[i].annualClaim == true)

{

if (patients[i].age > 60)

{

printf("The subscriber age has exceeded the limit(60 Year), Not Eligible");

return;

}

}

int j;

for (j = 0; j < patientCount; j++)

{

if (claims[j].id == patients[i].id)

break;

}

int amountToBeBorne = 0;

if (totalClaimAmount <= claims[j].remaininigAmount)

{

claims[j].amountClaimed += totalClaimAmount;

claims[j].remaininigAmount -= totalClaimAmount;

} else

{

amountToBeBorne = totalClaimAmount - claims[j].remaininigAmount;

claims[j].amountClaimed += (totalClaimAmount - amountToBeBorne);

claims[j].remaininigAmount = 0;

printf("\n\nThe amount that can be claimed is less then the claim by subscriber. %d RM should be given by subscriber themselves\n", amountToBeBorne);

}

FILE * fp;

fp = fopen("claims.txt", "w");

for (int i = 0; i < patientCount; i++)

fprintf(fp, "%d,%d,%d,%d\n", claims[i].id, claims[i].claimedYear, claims[i].amountClaimed, claims[i].remaininigAmount);

fclose(fp);

printf("Subscriber ID: %d\nSubscriber Name: %s\nSubscriber Claimed Year: %d\nSubscriber amount Claimed: %d\nSubscriber Remaining Claimed: %d\n", claims[j].id, patients[i].name, claims[j].claimedYear, claims[j].amountClaimed, claims[j].remaininigAmount);

system("pause");

}

In: Computer Science

Programming for business applications - (New to programming. Just learned arrays, for/if/ifelse/else, and tryParse method. Please...

Programming for business applications -

(New to programming. Just learned arrays, for/if/ifelse/else, and tryParse method. Please put comments so I am able to follow along with ease while doing this project.) C# is the language

Visual Studio 2019. Create a C# Console app (using .NET Framework)

Create a credit card console app. Each card has a Name, FICA score, and Credit Balance.

  • Prompt the user for the number of cards in this group
  • Declare/define 3 arrays (Names, FICA Scores, Balances) using the number entered by the user from 1 above
  • Prompt the user for the credit card user's Name, FICA score, and Credit Balance
    • Read in the input
    • Use TryParse when appropriate
    • If the input is invalid, loop until you get valid input
    • Names cannot be blank
    • FICA scores must be a value from 300 to 850 inclusive
    • Credit balance can be any valid decimal number ( positive or negative are okay)
    • Once the user's information is valid, put the data into the arrays
  • Display all the information to the console screen as shown below

   NAMES                      FICA          BALANCE

Ashley Bentley    700                $200.00

Berk Fields    850           $16,250.00

(the FICA scores and Balances are right aligned and the names are left aligned.)

In: Computer Science