# CSC2402 | C Assignment | Information Technology

Home Assignment Answers CSC2402 | C Assignment | Information Technology

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.

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.

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().

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!”.

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.

#### Latest Reviews

• ##### Kannon
13 Jul, 2019

I asked for essay help from Assignment Help 4 Me and I am happy that the essay writers completed my task on time. The prices they asked for are worth in comparison to the services rendered.

• ##### Liam
13 Jul, 2019

Assignment Help 4 Me is the best help provider. I took assistance to get my essay completed and I am glad that the writers delivered the quality content as they promised within the time committed.

• ##### Silas
12 Jul, 2019

Accounting is a very interesting subject but when it comes to assignment writing, I feel hard to get through the same. But, since the assignments have to be completed somehow, I preferred to avail online help from Assignment Help 4 Me. All thanks to them that they helped me complete my work on time at reasonable prices.