Professional Documents
Culture Documents
Part 1
Code Snippets – follow tasks requirements and provide code to attain required output/result
$people = array( 'Mary' => 17, 'Bob' => 62, 'John' => 32, );
function list_people($people) {
public static void main(String[] people)
{
String arrString[] = { "Mary", "Bob", "John" };
peoplename(arrString);
}
}
print list_people($people);
2. Sum all integers from $start to $end (included) and print the result.
$start = 1; $end = 3;
public class IntegerSumExample1 {
public static void main(String[] args) {
System.out.println("The sum of a and b is = " + Integer.sum($start, $end));
}
}
3. Script should print "Go outside" only if: it is NOT raining AND it is warm OR it is daytime.
import java.io.*;
class raining {
else
4. Write pseudo-code to display exactly 100 input box. Every 4th input box, display a 'x'.
for(int i = 1; i <= 100; i++) {
print i;
}
if ( i=4)
System.out.printIn (“x”)
class Discount
{
public static void main(String args[])
{
double dis,amount,markedprice,s;
markedprice=1000;
dis=20;
System.out.println("markedprice= "+markedprice);
System.out.println("discount rate="+dis);
s=100+dis;
amount= (s*markedprice)/100;
}
}