CSC2402 | C Assignment | Information Technology

Home Assignment Answers CSC2402 | C Assignment | Information Technology

Task 1

The first step is to create variables that will store the values of the name and distance entered by the user. Separate variables are used to store time, price according to the distance and time entered by the user. A variable will be initialized that will save the total bill calculated.

In the second step, user will input the details that include name, distance travelled (in kilometers) and duration of the journey (in minutes).

Third stage will display the name of the user (only first name will be displayed) and show the total calculated result. Including that, price according to the distance and duration will be shown as output.

Calculation of the total bill displayed:

Price calculation according to the distance entered(Travel cost):

A separate variable is used to store the value of distance entered by the user as it will be updated during the bill calculation. If distance entered is greater than 2, then for the first 2 kms $2.00 is added to the bill calculation variable. Now the distance will be decreased by 2. If the distance is less than 2 then also $2 will be added to the variable. After subtraction, if the distance is greater than 6 kms then $3 ($0.50*6) will be added to the bill and the value of distance is decreased by 6. If distance is less than 6 then $0.50 for each km will be added to the bill variable. Again, if the distance is greater than equal to 6, then $1 for each km will be added to the bill calculation variable.

Price calculation according to the duration entered(Time cost):

$2.00 for each minute will be added to the bill calculation variable.

After calculating both prices, addition of these prices takes place and displayed on the screen.

 

Task 2

This task prompts for an integer, validate the integer, and if not valid, ask again till a valid integer is entered.

First of all, variables for storing the values of day, month, year, hours, minutes and seconds are initialized.

Secondly, user will enter the year first. If the year entered will be in the range given, then it will move further but if the year is not valid then it will print the range of the year and ask the user to enter the year again.

For this, while loop has been used. The range of year is from 1970 to 2020. So while loop will work if the year entered is less than 1970 or greater than 2020. Input from the user will be taken again in the while loop.

Similarly, separate while loops will be used for checking the valid values entered by the user.

In the last step, all the data entered by the user will be displayed on the window.

Task 3

This task is same as of task 2 except functions are used in this task.

get_data() function will take input from the user and also checks the validation that is same as in task.We will declare and call get_data() function in main() method.

The entire logic(as in task 2) is now in get_data().

Output of this task is also same as task 2.

 

Task 4

This task will check whether an alphanumeric value has been entered or not.

If a valid value will be entered then a message will be displayed on the window.

We have created a get_option() method that will be used for taking input from user.Do-while loop has been used for validation check. Loop will be terminated  when valid input has been entered.

We have created another function ,that is test(char)(of string return type), which will be called when an alphanumeric value has been entered. The parameter of the function is that alphanumeric value. In this function if-else statements have been used.

  • If an upper case alphanumeric value has been entered, then it will print “An upper case letter is entered!”.
  • If a lower case alphanumeric value has been entered, then it will print “A lower case letter is entered!”.
  • If a digit has been entered, then it will print “A digit is entered!”.

Task 5

In this task, we will create a function ,i.e. get_string_component(char) and various other variables to store options, name, days, month, hour, minute, seconds, year entered by the user. We have used structure of ‘time’ library whose values will be according to the inputs entered.

Initially structure variable is set to the local time.

The following values will be taken from the user:

  • Name
  • Year
  • Month
  • Day
  • Hour
  • Minute
  • Seconds
  • 4 options

Validation loops have been used as used in the above tasks. After this, the values will be copied to in-built tm structure variable. These values will be passed to strftime() function.

Passing options as the parameter of the get_string_component(char) function.

If-else statements have been used to print the value according to the option entered by the user.

Strftime() function has been used for formatting the structure pointer according to the format specified in the function.

At last, all the values will be displayed on the window according to the options selected.

Search Here

Latest Reviews

  • Marcus
    30 Apr, 2019

    My assignment help services are provided in the best way by this website. The writers have completed my assignment in such a way that they helped me increase my overall performance.

  • Emy
    29 Apr, 2019

    Awesome work done by the experts of this company. I visited this site to get math assignment completed. My assignment was complete in every aspect. Thanks to the professionals who provided assignment writing help.

  • Darina
    25 Apr, 2019

    All thanks to the writers of Assignment Help 4 Me who completed my Physics assignment in the right manner. The structure of the assignment was totally customized according to my needs and that too at cheap prices.

View All Reviews

Facebook

Assignment Help 4 Me