Question

In: Electrical Engineering

PLEASE USE ASSEMBLY LANGUAGE The database students.db contains student records. Each record contains a name (30B...

PLEASE USE ASSEMBLY LANGUAGE

The database students.db contains student records. Each record contains a name (30B ASCII), student ID (9B ASCII), 3 grades out of 100 (3B integers), and a letter grade (1B ASCII).

For the file students.db described above, assume all records are ordered alphabetically based on the name field. A record for a new student has been entered and stored in memory. Determine how to insert the new record into the database (Hint: use string compares to determine where it goes, the create a temp file, copy record that should come before it into the temp, then copy new record, then all other record into temp file. The delete the original and rename the temp file to students.db.

Solutions

Expert Solution

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

struct info
{   
    int ID, HWORK, MIDTERM, FINAL, NUMGRADE;
    char NAME[20], LASTNAME[20];
} rec;

int main()
{
    FILE *fptr1, *fptr2;
    int NUMGRADE;
    char LETGRADE[3] = "";

    fptr1 = fopen("inf.txt.", "r");
    fptr2 = fopen("outf.txt.", "w");

    while(!feof(fptr1))
    {
        fscanf (fptr1, "%d %s %s %d %d %d", &rec.ID, rec.NAME, rec.LASTNAME, &rec.HWORK, &rec.MIDTERM, &rec.FINAL);

        NUMGRADE = rec.HWORK * 0, 15 + rec.MIDTERM * 0, 35 + rec.FINAL * 0, 5;

        if(NUMGRADE >= 0 && NUMGRADE <= 40) LETGRADE[3] = "FF";
        else if (NUMGRADE >= 41 && NUMGRADE <= 45) LETGRADE[3] = "DD";
        else if (NUMGRADE >= 46 && NUMGRADE <= 52) LETGRADE[3] = "DC";
        else if (NUMGRADE >= 53 && NUMGRADE <= 60) LETGRADE[3] = "CC";
        else if (NUMGRADE >= 61 && NUMGRADE <= 69) LETGRADE[3] = "CB";
        else if (NUMGRADE >= 70 && NUMGRADE <= 79) LETGRADE[3] = "BB";
        else if (NUMGRADE >= 80 && NUMGRADE <= 89) LETGRADE[3] = "BA";
        else if (NUMGRADE >= 90) LETGRADE[3] = "AA";        

        fprintf (fptr2, "%d %s %s %d %s", &rec.ID, rec.NAME, rec.LASTNAME, &NUMGRADE, LETGRADE);        
    }

    fclose(fptr1);
    fclose(fptr2);

    return 0;
}

Related Solutions

The language is Assembly Language. Thank you! Assignment 3: Run the following code. Record what each...
The language is Assembly Language. Thank you! Assignment 3: Run the following code. Record what each of the flag changes are for each command. INCLUDE Irvine32.inc .data .code main PROC mov al,255 add al,1 call DumpRegs sub al,1 call DumpRegs sub al,1 call DumpRegs exit main ENDP END main
Using MIPS (MARS) - Assembly Language Assignment ( PLEASE USE COMMENTS TO DESCRIBE EACH STEP )...
Using MIPS (MARS) - Assembly Language Assignment ( PLEASE USE COMMENTS TO DESCRIBE EACH STEP ) Take input of name, the input of hours worked, and input of hourly wage, and use input of hourly wage and hours worked to calculate total paycheck and print Name, and paycheck.
Write an assembly language program that prints your first name in the output. Use immediate addressing...
Write an assembly language program that prints your first name in the output. Use immediate addressing with a hexadecimal constant to designate the operand of CHARO for each letter of your name. Comment each line except STOP and END. Cut and paste the Assembler Listing into your document and paste a screen shot of the Output area of the Pep8. Use the name "Kevin" as example Assembler Listing Screen Shot of Output area of the Pep8 program
Hi this is Assembly Language MASM x86 program. Please write it in the language and please...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please explain it with comments thank you Please answer it I really need help this question was refunded before so please answer. Thank you so much also these are two separate programs thank you. 1) Write a procedure to read in decimal or hex number (byte-sized) Then write a procedure using shifts and ANDS to convert the string to a binary number (if is backward,...
Please complete in MASM (x86 assembly language). Use the code below to get started. Use a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Use a loop with indirect or indexed addressing to reverse the elements of an integer array in place. Do not copy the elements to any other array. Use the SIZEOF, TYPE, and LENGTHOF operators to make the program as flexible as possible if the array size and type should be changed in the future. .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your...
Assume that the instruction pointer, EIP, initially contains 2010 and the assembly language representation of the...
Assume that the instruction pointer, EIP, initially contains 2010 and the assembly language representation of the instructions in memory starting at address 2010 is Instruction Address Instruction 20 CMP DL, 0xD2 21 JE 72 Before the instruction sequence is executed, the flags are CF=0, ZF=0 and SF=0 and the Registers have the values AL=0x0D, BL=0xA9 CL=0x5E andDL=0xCF. What is the value of the instruction pointer after the sequence executes?
Please use assembly language x86 Visual Studio Write a program to add the following word size...
Please use assembly language x86 Visual Studio Write a program to add the following word size numbers:15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
Convert to Assembly Language M3 (please use as CMP R1, #3 ....) #include #include int main()...
Convert to Assembly Language M3 (please use as CMP R1, #3 ....) #include #include int main() { int r1 = 3; int r2 = 15; int r3 = 0; if (r1 <= r2) { for (int n = r1; n <= r2; n++) { r3 += (50 - n - n + r1 + r2); } } else { r3 = abs(r1) + abs(r2); } return 0; }
A college records the module registration information of their students in a database named College.mdb,which contains...
A college records the module registration information of their students in a database named College.mdb,which contains three tables,STUDENT,MODULE andMODULE_REG. A student may enroll in the same module as many times as they like. However, they can only enroll each module at most once in each semester. The design of the three tables are shown below: Table STUDENT Field Name Data Type Note SID Short Text primary key FirstName Short Text LastName Short Text Contact Short Text Gender Short Text “M”...
C++ Write a definition for a structure type for records for books. The record contains ISBN...
C++ Write a definition for a structure type for records for books. The record contains ISBN number, price, and book cover (use H for Hard cover and P for paper cover). Part of the problem is appropriate choices of type and member names. Then declare two variables of the structure. Write a function called GetData use the structure as function argument to ask the user to input the value from the keyboard for structure variables.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT