Estou seguindo o livro indicado pelo professor Julio ( CSharp 3 Beginners Guide ) encontrei o exercício a seguir, bacaninha me sinto no comecim de ATP de novo kkkkk, para melhorar um pouquim adicionei a conversão de milhas para Km.

Talk to Mars
At its closest point to Earth, Mars is approximately 34 million miles away. Assuming there
is someone on Mars you want to talk with, what is the delay between the time a radio signal
leaves Earth and the time it arrives on Mars? This program supplies the answer. Recall that light
travels approximately 186,000 miles per second. Thus, to compute the delay, you will need to
divide the distance by the speed of light. Display the delay in terms of seconds and minutes.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Talk_to_Mars
{
class Program
{
static void Main(string[] args)
{
double M_distancia = 34000000; // valor em milhas
double M_velocidade = 186000; // valor em milhas por segundo (converter)

//Convertendo;
double distancia = M_distancia * 1.609; //1 milha = 1,609 km.
double velocidade = M_velocidade * 1.609;

double atraso = distancia / velocidade;

Console.WriteLine("O atraso e de: {0:#.###} segundos", atraso); // Atraso em segundos
Console.WriteLine("O atraso e de: {0:#.###} minutos", (atraso / 60)); // Atraso em minutos
Console.ReadLine();
}
}
}

0 comentários: