terça-feira, 20 de janeiro de 2015

Exercício C# - 1

Elaborar um programa que, de acordo com a hora atual, escreva "bom dia" ou "boa tarde", consoante a hora atual seja igual ou inferior às 12h ou maior do que as 12h.

A hora atual pode ser obtida com DateTime.Now.Hour que devolve um valor do tipo int.

Apresentar o código correspondente a à resolução do exercício num comentário a este post.


11 comentários:

Ricardo L disse...

/*
* Created by SharpDevelop.
* User: Ricardo
* Date: 20/01/2015
* Time: 09:41
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace derp
{
class Program
{
public static void Main(string[] args)
{
int horas;
horas = DateTime.Now.Hour;
if(horas>=12)
{Console.WriteLine("Boa tarde");
}
else
{Console.WriteLine("Bom Dia");

}
Console.ReadKey (true);





}
}
}

Ricardo Lage n° 21
Rui monte n° 25

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Ruben e Ronaldo
* Date: 20/01/2015
* Time: 09:45
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace Ruben
{
class Program
{
public static void Main(string[] args)
{
int hora = DateTime.Now.Hour ;
DateTime horaDois = DateTime.Now;

if (hora >= 8 && hora <= 12) {
Console.WriteLine("Bom dia, sao {0:t}.", horaDois);
}else if (hora > 12 && hora <= 18) {
Console.WriteLine("Boa tarde, sao {0:t}.", horaDois);
}else{
Console.WriteLine("Boa noite, sao {0:t}.", horaDois);
}
Console.ReadLine();
}
}
}

Tiago Monteiro disse...

/*
* Created by SharpDevelop.
* User: Tiago Monteiro nº28 e Diogo Matos nº6
* Date: 20/01/2015
* Time: 09:56
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace hora_atual
{
class Program
{
public static void Main(string[] args)
{
int hora;
hora = DateTime.Now.Hour;
if(hora<=12){
Console.WriteLine("Bom dia");
}
else{
Console.WriteLine("Boa Tarde");
}
Console.WriteLine("Clica em qualquer tecla.....");
Console.ReadKey();
}
}
}

Alex Trifyutsyanu disse...

/*
* Created by SharpDevelop.
* User: Alex
* Date: 20/01/2015
* Time: 09:50
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace ex1
{
class Program
{
public static void Main(string[] args)
{
int hora = DateTime.Now.Hour;

if(hora < 12) {
Console.WriteLine ("Buenos diogos, sao {0:d} horas",hora);
}
else {
Console.WriteLine("Buenas Tardes, sao {0:d} horas",hora);
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Diogo e helderrrr
* Date: 20/01/2015
* Time: 09:41
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace sahshashashahshsa
{
class Program
{
public static void Main(string[] args)
{
int hora = DateTime.Now.Hour ;
DateTime horaDois = DateTime.Now;

if (hora >= 8 && hora <= 12) {
Console.WriteLine("Bom dia, sao {0:t}.", horaDois);
}else if (hora > 12 && hora <= 18) {
Console.WriteLine("Boa tarde, sao {0:t}.", horaDois);
}else{
Console.WriteLine("Boa noite, sao {0:t}.", horaDois);
}
Console.ReadLine();
}

Anónimo disse...


* User: Marcelo
* Date: 20/01/2015
* Time: 10:23
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace Horas
{
class Program
{
public static void Main(string[] args)
{
int hour;
hour = DateTime.Now.Hour;
if(hour>=12)
{Console.WriteLine("Bom Dia");
}
else
{Console.WriteLine("Boa Tarde");

Anónimo disse...


* User: Marcelo e Tiago
* Date: 20/01/2015
* Time: 10:23
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace Horas
{
class Program
{
public static void Main(string[] args)
{
int hour;
hour = DateTime.Now.Hour;
if(hour>=12)
{Console.WriteLine("Bom Dia");
}
else
{Console.WriteLine("Boa Tarde");

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Diogo / Sencadas
* Date: 20-01-2015
* Time: 09:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace MOD4_Exercicio1
{
class Program
{
public static void Main(string[] args)
{int hora = DateTime.Now.Hour;
if(hora < 12)
{Console.WriteLine("Good Morning its {0:d} ",hora);
}
else
Console.WriteLine ("Good Afternoon, its {0:d}",hora);
Console.ReadKey();
}}}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: Carlos C.
* Date: 20/01/2015
* Time: 09:50
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace derp
{
class Program
{
public static void Main(string[] args)
{
int horas;
horas = DateTime.Now.Hour;
if(horas>=12)
{Console.WriteLine("Boa tarde :)");
}
else
{Console.WriteLine("Bon Dia :)");

}
Console.ReadKey (true);





}
}
}


Carlos correia nº3
Nuno Sol nº16

Anónimo disse...

/*
* Created by SharpDevelop.
* User: pedro
* Date: 20/01/2015
* Time: 10:32
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace pedro
{
class Program
{
public static void Main(string[] args)
{
int h = DateTime.Now.Hour ;
DateTime day= DateTime.Now;

if (h>= 8 & h <= 12) {
Console.WriteLine("Bom dia, sao {0:t}.",day );
}else if (h > 12 & h <= 18) {
Console.WriteLine("Boa tarde, sao {0:t}.", day);
}else{
Console.WriteLine("Boa noite, sao {0:t}.", day);
}
Console.ReadLine();
}}}

Anónimo disse...

/*
* Created by SharpDevelop.
* User: luis carreira e luis costa
* Date: 20/01/2015
* Time: 10:55
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;

namespace work
{
class Program
{
public static void Main(string[] args)
{
int hora = DateTime.Now.Hour ;
DateTime work= DateTime.Now;

if (hora>= 8 & hora <= 12) {
Console.WriteLine("Bom dia, sao {0:t}.",work );
}else if (hora > 12 & hora <= 18) {
Console.WriteLine("Boa tarde, sao {0:t}.", work);
}else{
Console.WriteLine("Boa noite, sao {0:t}.", work);
}
Console.ReadLine();
}}}