In: Computer Science
Complete the 3 programming problems in this assignment by using
Microsoft Visual Studio Suite. Compile your solutions for each
problem solved in a Word or Google document which includes (a) the
pseudocode, (b) the C# codes and (c) the execution result (screen
capture just the answer part using Snipping Tool, avoiding
non-related or blank spaces). Notice for readability, that the (a)
& (b) are in text mode and the (c) is in image mode. Use proper
titles and wording in the results, such as Console.WriteLine("The
total change to be made is {0:C}.", change); so that the results
could be easily understood by a third party reader. For all 3
questions, assign the provided initial values to the variables or
constants in the source code as input.
You may need to save the snipped image as a JPG file and then
insert the file into the document, especially when you use a Google
doc. Create just one document for all 3 solutions in this
assignment. You may create the document directly from a cloud
service or from you PC first and then upload it to a cloud. The
possible cloud service could be Google Drive, Microsoft OneDrive,
Dropbox, etc. To submit the document, click the "Write Submission"
button under this assignment. Then use the opened editor box to
submit the web address of your document on the cloud or, if you are
not yet able to use a cloud service, submit the document as an
attached file.
Q3. Write a C# program to convert one billion seconds (1,000,000,000 seconds) into years, months, days, hours, minutes, and seconds. And compute how many seconds are in 20 years, including 5 leap years.
using System;
namespace Billionseconds
{
class Program
{
static void Main(string[] args)
{
TimeSpan t = TimeSpan.FromSeconds(1000000000);
var Years = (t.Days / 365);
var months= ((t.Days) % 365)/30;
var Days = (t.Days % 365) % 30;
var Hours=(t.Hours);
var minutes=(t.Minutes);
var seconds=(t.Seconds);
Console.WriteLine(" {0} year(s), {1} month(s) {2} day(s) {3}
hour(s) {4} minute(s) {5} and second(s)", Years,
months,Days,Hours,minutes,seconds);
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------
using System;
namespace yearstoseconds
{
class Program
{
static void Main(string[] args)
{
var years = 20;
//extra leapyear days are added
var totaldays = (years*365)+(years / 4);
int seconds = (totaldays * 86400);//1day=86400 seconds
Console.WriteLine("Total seconds:" + seconds);
}
}
}