100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Otro

Brunel - Computer Science - CS1702 Introductory Programming Lab Worksheets

Puntuación
-
Vendido
-
Páginas
26
Subido en
06-01-2024
Escrito en
2018/2019

CS1702 Introductory Programming Lab Worksheets

Institución
Grado










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Desconocido
Grado

Información del documento

Subido en
6 de enero de 2024
Número de páginas
26
Escrito en
2018/2019
Tipo
Otro
Personaje
Desconocido

Temas

Vista previa del contenido

public class CS1702_Lab2 {

public static void main(String args[])
{
long a,g,x;
double b,c,y;
boolean d;
final double pi;
String e,f,h,z,name;



a=100;
b=2.3;
c=-52.2;
d=true;
e="I am ";
f="a student";
g=0;
h="!";
pi=3.142;
name=" sadiq ";


//Q1
y=a+b;
System.out.println(y);
//Q2
System.out.println("no answer");
//Q3
z=e+f;
System.out.println(z);
//Q4
y = b*c;
System.out.println(y);
//Q5
System.out.println("no answer");
//Q6
System.out.println("no answer");
//Q7
System.out.println("no answer");
//Q8
x=10;
System.out.println(Math.pow(x,3));
//Q9
z=name+" is "+f+h;
System.out.println(z);
//Q10
System.out.println("no answer");
//Q11
System.out.println("no answer");
//Q12
y=100.3;
y=(y/(a + b))-c;
System.out.println(y);
//Q13
System.out.println("no answer");
//Q14
System.out.println("no answer");
//Q15
y=((pi+1)/(pi+2))/(pi+3);
System.out.println(y);
//Q16
y=-2;
System.out.println(Math.pow((Math.pow(y, 2)/b),(1.0/3.0)));
//Q17
System.out.println("no answer");
//Q18
z=name;
z=b/g+z;
System.out.println(z);
//Q19
y=-2.3;
y=a*(Math.pow(y,2))+b*y+c;
System.out.println(y);
//Q20
System.out.print("no answer");




}


}

,1.) 102.3
2.) No answer (Boolean error)
3.) I am a student
4.) -120.06
5.) No answer (pi is constant)
6.) No answer (string / 0)
7.) No answer (z is string)
8.) 1000.0
9.) sadiq is a student!
10.) No answer
11.) No answer
12.) 53.18044965786902
13.) No answer (string)
14.) No answer (cant subtract a char)
15.) 0.13114997439694126
16.) 1.2025709773288682
17.) No answer (cannot divide by 0)
18.) Infinity sadiq
19.) 471.50999999999993
20.) No answer

, CS1702 Introductory Programming (2018-2019)



Laboratory 3 – Week 4
Conditional Statements in Java
3.1 Introduction

The laboratory session covers conditional statements in Java. Again we will be implementing
some of the examples given during the lecture, followed by some additional examples. We
will then look at a few sections of the help pages.

Note that: this worksheet is one of the worksheets from which your laboratory
worksheets portfolio of work will be assessed [CodeRunner tests].

3.2 Relational operators

Create a new project and Java class called CS1702_Lab3. Add the following code:
static public void main(String args[])
{
int a = 1000,b = -22;

if (a < b)
{
System.out.println("a is less than b");
}
else
{
System.out.println("a is NOT less than b");
}
}


Run the program. It should display the message “a is NOT less than b”. Test the program on a
number of different values of a and b such that both parts of the if statement is run. Now
add a similar set of program code that tests if a is greater than b.

Using the above code “snippet” as a basis, write a set of Java if statements that determines if
the following statements are true, note that you must declare the variables first and choose the
correct type.

Let x = 100, y = 204, z = -23.1, a = true, b = false, c = -204

1) x<y
2) x > z and a = b
3) 2c > y
4) x=b
5) c ≠ y or c = y
6) z ≠ y and c = a
7) y ≥ y and a+3 ≠ 2




3/26

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
cslbrunel Brunel University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
63
Miembro desde
3 año
Número de seguidores
34
Documentos
29
Última venta
4 meses hace
Brunel Computer Science (1st Class Honours)

I achieved a First Class Honours degree in Computer Science from Brunel University - I will be uploading some of my work. Please do not purchase any documents looking for the solution to your assignments or deliverables. No refunds / exchanges.

5.0

2 reseñas

5
2
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes