Question

Cloud computing uses the internet and central remote servers to maintain data and applications. It is...

Cloud computing uses the internet and central remote servers to maintain data and applications. It is essentially a resource delivery and usage model to get infrastructure, platforms, and software through the internet. A cloud provider supplies a pool of resources to consumers. On-demand instances are paid by the hour with no long-term commitments. Reserved instances allow the consumer to make a one-time payment for each instance reserved and receive a significant discount on the hourly usage charge.

The pricing structure of a cloud provider that provides on-demand instances is stored in a data file (price.txt). Each line of the data file contains the instance ID, memory, computing capacity, and prices in the Windows environment, in that order. The file is space delimited and contains a control number.

ASSIGNMENT: Write a C program to read the pricing structure from the data file. Since you are interested in services providing between 1 and 20 GB of memory, print the instance ID, memory, computing capacity, and price in $/hr for the instances which have between 1 and 20 GB of memory. For all other instances, print the instance ID followed by a message (memory is either too high or too low). Print the table to the computer screen and to an output file called screened.txt.

Use the “Code Sections.c” template on Blackboard to write your code.

Your program output will look like the illustration shown below. Use your PC’s cursor to determine the horizontal and vertical spacing for the output format.

SAMPLE OUTPUT FORMAT:

********************************************

CLOUD COMPUTING PRICES

Instance Memory Computing Price

ID (GB) Capacity (GB) ($/h)

x xx.x xx x.xx

x      ** Memory is too large **

   x      ** Memory is too small **

** ********************************************

10
1 1.7 1 0.11
2 7.5 4 .48
3 15 8 .94
4 0.5 2 .03
5 1.7 5 .62
6 6.5 10 1.22
7 17.1 6 .64
8 34.6 12 1.20
9 69.5 24 2.56
10 20 32 1.98

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Screenshot:

Sample Output:

Note: I have done the formatting as per the question. If some specific formatting is required, do tell.

Program code to copy:

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

// main function
int main()
{
// structure pointer variable is declared of type struct FILE
FILE *fin, *fout;
// variables are declared
int n;
int instanceID, computingCap;
float memory, price;
  
// files are opened for reading and writing
fin = fopen("price.txt","r");
fout = fopen("screened.txt", "w");
  
// error catching
if(fin == NULL){
printf("Error opening file price.txt\n");
exit(1);
}
// error catching
if(fout == NULL){
printf("Error opening file screened.txt\n");
exit(1);
}
  
// reading first line of file "price.txt"
fscanf(fin, "%d\n", &n);
// strings that are used for output formatting
char str1[] = "********************************************\n";
char str2[] = "CLOUD COMPUTING PRICES\n";
char str3[] = "Instance Memory Computing Price\nID (GB) Capacity (GB) ($/h)\n";
printf("%s%s%s", str1, str2, str3);
fprintf(fout, "%s%s%s", str1, str2, str3);
  
// while loop to read in the input and write to another file
while(fscanf(fin,"%d %f %d %f\n", &instanceID, &memory,
&computingCap, &price) != EOF){
// if memory too small
if(memory < 1.0){
printf("%d ** Memory is too small **\n",instanceID);
fprintf(fout, "%d ** Memory is too small **\n",instanceID);
}
// if memory too large
else if (memory > 20.0){
printf("%d ** Memory is too large **\n",instanceID);
fprintf(fout, "%d ** Memory is too small **\n",instanceID);
}
// if memory is perfect
else{
printf("%d %.1f %d %.2f\n", instanceID, memory, computingCap, price);
fprintf(fout, "%d %.1f %d %.2f\n", instanceID, memory, computingCap, price);
}
}
// printing out output format
printf("%s",str1);
fprintf(fout, "%s", str1);
  
// closing the files
fclose(fin);
fclose(fout);
// returning 0
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Cloud computing uses the internet and central remote servers to maintain data and applications. It is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 73 What AwS database service is used for data warehousing of petabytes of data? ORDS...

    QUESTION 73 What AwS database service is used for data warehousing of petabytes of data? ORDS Elasticache O Redshih DynamoDB QUESTION 74 What AWS tool compares the cost of running your application in an on-premises data center to AWS? Total Cost of Application (TCA) calculator Total Cost of Products (TCP) calculator Total Cost of Ownership (TCO) calculator Total Cost of Operation (TCO) calculator QUESTION 75 What SQL database engine options are available in RDS? (Choose 3 correct answers) MySQL MongoDB...

  • C Programming - Please Help us! Implementing Load Balancing, the 3 Base Code files are at the bot...

    C Programming - Please Help us! Implementing Load Balancing, the 3 Base Code files are at the bottom: Implementing Load Balancing Summary: In this homework, you will be implementing the main muti-threaded logic for doing batch based server load balancing using mutexes Background In this assignment you will write a batch-based load balancer. Consider a server which handles data proces- sing based on user requests. In general, a server has only a fixed set of hardware resources that it can...

  • Santa Monica College CS 20A: Data Structures with C++ Spring 2019 Name: True/False: Circle one Assignment...

    Santa Monica College CS 20A: Data Structures with C++ Spring 2019 Name: True/False: Circle one Assignment 1 ID: 1. True / False 2. True / False 3. True / False 4. True / False 5. True / False 6. True / False 7. True / False 8. True / False 9. True / False 10. True / False Variable and functions identifiers can only begin with alphabet and digit. Compile time array sizes can be non-constant variables. Compile time array...

  • A test specification provides designers with what needs to be known in order to perform a...

    A test specification provides designers with what needs to be known in order to perform a specific test, and to validate and verify the requirement to be tested. The test script is divided into the test script, which is the generic condition to be tested, and one or more test cases within the test script. Provide a test script and test case for at least 3 of your requirements identified in your requirements specification. Provide the following format for an...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT