You are on page 1of 3

#include <iostream>

#include <string>

using namespace std;

int main ()
{
int score = 0;
int score1 = 0, score2 = 0;
string team1 = "", team2 = "";

// get the names of the two Teams


getline(cin, team1);

cout << team1 << endl;


getline(cin, team2);

//Get the score of two teams


cout << "what is the score of" << team1 << " ? ";
cin >> score1;

cout << "What is the score of" << team2 << " ? ";
cin >> score2;
if(score1 < 0 || score2 < 0){
cout << "ERROR: Score cannot be negative." << endl;

return -1;

//Output the name of the winning team


if(score1 < 0 || score2 < 0){
cout << team1 << " WON!" << endl;

}
else if(score1 == score2){
cout << team1 << " and " << team2 << " ARE TIED! " << endl;

else{
cout << team2 << " WON! " << endl;
}
return 0;
}
java.util.Scanner;

public class OddEven


{
public static void main (string[] args)
{
scanner input = new scanner(System.im);

System.out.println("Enter a number:");

int num = input.nextInt();

if(num % 2 == 0)
System.out.pintln(num + " is Even");
else
System.out.println(num + " is Odd");

}
}
import java.util.Scanner;
public class calculator{
public static void main (String[] args)
{
Scanner input1 = new Scanner(System.in);
System.out.println("*** CALCULATOR ***");
System.out.println("Enter 2 numbers:");

int input= input1.nextInt();


int input2 =input1.nextInt();
System.out.println("Arithmetic Operations:");
System.out.println("Press 1 for Addition:");
System.out.println("Press 2 for Subtraction");
System.out.println("Press 3 for Multiplication");
System.out.println("Press 4 for Division");

System.out.println("Choose Operation:");
int Choose=input1.nextInt();

if (Choose == 1)
System.out.println("Result-->"+ input + " + " + input2 + "=" + (input + input2 ));

else if(Choose == 2)

System.out.println("Result-->"+ input + " - " + input2 + "=" + (input - input2 ));

else if(Choose == 3)
System.out.println("Result-->"+ input + " * " + input2 + "=" + (input * input2 ));

else
System.out.println("Result-->"+ input + " / " + input2 + "=" + (input / input2 ));
}
}

You might also like