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

For C++, visual studio Write a program or function for each of the following. If

ID: 665559 • Letter: F

Question

For C++, visual studio

Write a program or function for each of the following. If you write a function, make sure you have a main program that tests the function. Include code and a sample run for each problem.

Write a program that simulates rolling a six sided die. Find the expected number of rolls (average) required to roll four 3’s in a row.

Write a program that 3creates a structure (a C struct) to hold student information. The information should include Last Name, First Name, Number of credits completed, and Date of enrollment. The main program should allow the user to enter information on a student and then print out the information that was entered.

Write a program that allows the user to enter in multiple students (use the structure from problem 3 and create an array of students.) The program should then print the names and enrollment date of all students with 128 credits or more.

Use the array of students from problem 4. The program should then enter a loop that allows the user to enter a student last name. The program should then print the remaining information for that student or students. The program should repeat this process until the user wants to quit.

Explanation / Answer

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


void main(int argc, char* argv[]) {

const int TRIALS = 100000;
int trial;
int die;
static int rolls = 0;
static int totalRolls = 0;
double x;

srand(time(0));

for (trial = 0; trial < TRIALS; ++trial) {
    while (rolls != 4) {
    die = (rand() % 6 + 1); //probability of dies with 6 faces
    ++totalRolls;
    if (die == 3) {
    ++rolls;
    }
    else {
        rolls = 0;
    }

}
}
x = (totalRolls / TRIALS);
printf("%d ", totalRolls);
printf("%.2lf", x);
getchar();
getchar();
}

#include <stdio.h>
#include <string.h>
// Last Name, First Name, Number of credits completed, and Date of enrollment.

struct student
{
            int id,credits_comp;
            char fname[20],lname[20],dateofEnr[20];
            float percentage;
};

void func(struct student record);

int main()
{
            struct student record;

            record.id=1;
            strcpy(record.fname, "Raju");
           strcpy(record.lname, "david");
            record.credits_comp=4;
           strcpy(record.dateofEnr, "aug82015");
            record.percentage = 86.5;

            func(record);
            return 0;
}

void func(struct student record)
{
            printf(" Id is: %d ", record.id);
            printf(" Name is: %s ", record.fname"+"record.lname);
           printf(" credits completed ",record.credits_comp);
           printf("Date of enroll ment ",record.dateofEnr);
            printf(" Percentage is: %f ", record.percentage);
}

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