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

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
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...
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.
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”...
Write a MIPS Assembly language program to request a file name from the user, open the...
Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write out the contents to the console. This is what I have so far: .data    fileName:   .space 100    prompt1:   .asciiz "Enter the file name: "    prompt2:    .asciiz ""    prompt3:   .asciiz "\n"    buffer:    .space 4096 .text    main:        #        li $v0, 4        la $a0, prompt1       ...
In the C# programming language... Write a program to perform student record manage for class IST311....
In the C# programming language... Write a program to perform student record manage for class IST311. Create student record class (Student.cs) and it should get the student information from the user and set up student record class. The program will perform recording student’s grade information and compute final grade, and then print out the student’s class information. Student class definitions: It should contain attributes as following: first name, last name, 5 labs grade, 3 grade, final grade. Its member functions...
Change program linkedListClass to the linked list for student items (a student item contains id, name...
Change program linkedListClass to the linked list for student items (a student item contains id, name and score, where the id is used as key) and test it in the main method. You can define a student item using a class of student. given the following codes; import java.util.*; public class linkedListClass {    public Node header;    public linkedListClass()    {        header = null;    }    public final Node Search(int key)    {        Node...
IN JAVA ECLIPSE PLEASE The xxx_Student class A Student has a: – Name - the name...
IN JAVA ECLIPSE PLEASE The xxx_Student class A Student has a: – Name - the name consists of the First and Last name separated by a space. – Student Id – a whole number automatically assigned in the student class – Student id numbers start at 100. The numbers are assigned using a static variable in the Student class • Include all instance variables • Getters and setters for instance variables • A static variable used to assign the student...
Write a sequence of assembly language instructions to subtract each entry of an array A of...
Write a sequence of assembly language instructions to subtract each entry of an array A of five two’s complement 16-bit binary integers from the corresponding entry of an array B of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i]. Use the following data for the arrays A and B. A: 10, -15, 20, 4, -5 B: 25, -5, -30, 6, 10 please answer in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT