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

Hello, I have a programming assignment that I could really use help with. I need

ID: 3701211 • Letter: H

Question

Hello, I have a programming assignment that I could really use help with. I need it to be done following the instructions below, If anyone could help me I would really appreciate it. Please dont rush the process, take your time and complete it fully and ensure its functionality before posting your answer. there is another solution on this website for a similar question but is incorrect so please dont just copy the other one. I would really appreciate your help, I will gladly post comments after its finished and rate according to my requests.  

Part 1 (data input) Write a C program that prompts the user to enter some data regarding some clients to a business. The user should prompt for customer account number (a positive integer between 1 and 1000), a last name (a string), and their account balance (a positive floating point number) as shown below. Notice how the user input terminates once the user enters a -999 as the account number: Enter account number, last name, and balance Enter -999 to end input ? 100 Smith 24.98 8000 Jones 334.33 ***Invalid account number. Please enter 1-1000 or -999 to exit ** 800 Jones 334.33 ? 400 Johnson 56.55 300 Roberts -330.90 *nvalid balance amount. Please enter a positive value. 300 Roberts 330.90 500 White 0.00 ?-999 (What the user types in is shown in blue for clarity only.) You could store this information in either 3 separate arrays or in an array of tvpe struct Make the array sizes large enough to hold data for up to 5 clients Part 2 (data output)

Explanation / Answer

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

// structure to hold data
struct BankData
{
   int accNO;
   char Name[20];
   float Balance;
};


int main()
{
   int i,a,b;
   // max 20 data can be stored can be extend it
   struct BankData data[20];
   struct BankData temp; //temp strucutre to swap data in sorting
   printf("Enter Account_Number Last_name Balance ");
   printf("Enter -999 to end ");
   for(i=0;i<20;i++)
   {
      
       fflush(stdin);
       //syncfs(0);
       scanf("%d",&(data[i].accNO));
       if(data[i].accNO == -999)
       {
           fflush(stdin); //every time need to clear extra input which will not be used
           break;
       }
       scanf("%s %f",(data[i].Name),&(data[i].Balance));
       if(data[i].accNO >1000 || data[i].accNO <1)
       {
           fflush(stdin); //every time need to clear extra input which will not be used
           printf("********Invalid ACC No. Please enter valid acc no between 1 to 1000 or -999 to exit ");
           i--;   // invalid input so no need to increment count.....!
           continue;
       }
       if(data[i].Balance < 0)
       {
           fflush(stdin); //every time need to clear extra input which will not be used
           printf("Please enter positive balance or -999 to exit ");
           i--;   // invalid input so no need to increment count.....!
           continue;
       }
   }

// sorting data by selection sort by account number

// each account number compare with every acc number start from next
   for(a=0;a<i-1;a++)
       for(b=a+1;b<i;b++)
       {
           if(data[a].accNO > data[b].accNO)
           {
           // if acc number is greater then swap it
               temp.accNO = data[a].accNO;
               strcpy(temp.Name,data[a].Name);
               temp.Balance = data[a].Balance;

               data[a].accNO = data[b].accNO;
               strcpy(data[a].Name,data[b].Name);
               data[a].Balance = data[b].Balance;

               data[b].accNO = temp.accNO;
               strcpy(data[b].Name,temp.Name);
               data[b].Balance = temp.Balance;
           }

       }
   printf("-------------------------------- ");
   printf("ACC_NO     NAME     BALANCE ");
   printf("-------------------------------- ");
//printing sorted data
   for(a=0;a<i;a++)
   {
       printf("%d       %s      %f ",data[a].accNO,data[a].Name,data[a].Balance);
   }
}

/*

OUTPUT:

Enter Account_Number Last_name Balance Enter -999 to end
200
john 36.00               // valid
120 can 36.66               // valid
126
mor 123.66               // valid
-9
komm 346.11
********Invalid ACC No. Please enter valid acc no between 1 to 1000 or -999 to exit
1354 ram -999
********Invalid ACC No. Please enter valid acc no between 1 to 1000 or -999 to exit
100 ram -900
Please enter positive balance or -999 to exit
100 ram 100.125                // valid
-999
--------------------------------
ACC_NO     NAME     BALANCE
--------------------------------
100   ram 100.125000
120   can 36.660000
126  
mor 123.660004
200  
john 36.00
*/

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