Examination- ADF1 - Java Basic - Thi thực hành - T1907A
Thời Gian Bắt Đầu Thi : 15:20 - 16:20
Các bạn làm xong thi upload code lên chủ đề này cho thầy.
Gửi bài chậm 1 phút -> trừ 0.5 điểm
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Ngô Quang Huy [C1907L]](https://www.gravatar.com/avatar/8e54dbf5994077ce599f49278164ae79.jpg?s=80&d=mm&r=g)
Ngô Quang Huy
2020-04-06 14:04:01
package April6FPT;
public class ConversionUtil {
public double fahrenheitToCelsius(double fDegree){
double celcius = 5*(fDegree - 32)/9;
return celcius;
}
public double celciusToFahrenheit(double cDegree){
double fahrenheit = 9*cDegree/5 + 32;
return fahrenheit;
}
}
package April6FPT;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
ConversionUtil util = new ConversionUtil();
System.out.println("Choose Type of degree: ");
System.out.println("1. Celcius ");
System.out.println("2. Fahrenheit ");
System.out.print("Choose: ");
Scanner input = new Scanner(System.in);
int choose = input.nextInt();
System.out.print("Insert Degree: ");
int degree = input.nextInt();
if(choose == 1){
System.out.println("The Fahrenheit degree of "+degree+" is "+util.celciusToFahrenheit(degree));
}else{
System.out.println("The Celcius degree of "+degree+" is "+util.fahrenheitToCelsius(degree));
}
}
}
package April6FPT;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Insert String: ");
StringTokenizer b = new StringTokenizer(input.nextLine());
System.out.println("Result: ");
while(b.hasMoreTokens()){
System.out.println("\t"+b.nextToken());
}
}
}
![tuananh [T1907A]](https://www.gravatar.com/avatar/13a63a98965308e7158a1d51493a96b4.jpg?s=80&d=mm&r=g)
tuananh
2020-03-18 09:53:39
package Tuan;
/**
*
* @author Tuan
*/
public class ConversionUtil {
public double fahrenheitToCelsius(double fDegree) {
return 5 * (fDegree - 32) / 9;
}
public double celciusToFahrenheit(double cDegree) {
return (9 * cDegree / 5) + 32;
}
}
package Tuan;
import java.util.Scanner;
/**
*
* @author tuan
*/
public class Exam1 {
public static void main(String[] args) {
ConversionUtil cv = new ConversionUtil();
Scanner sc = new Scanner(System.in);
System.out.println("Nhập vào độ Celcius cần đổi: ");
double cecius = sc.nextDouble();
System.out.println(cecius + " độ C = " + cv.celciusToFahrenheit(cecius) + " độ F");
System.out.println("Nhập vào độ Fahrenheit cần đổi: ");
double fahrenheit = sc.nextDouble();
System.out.println(cecius + " độ F = " + cv.fahrenheitToCelsius(fahrenheit) + " độ C");
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tuan;
import java.util.Scanner;
/**
*
* @author tuan
*/
public class Exercise2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Please enter text: ");
String text = scanner.nextLine();
String[] name = text.split(" ");
for (String mainName: name) {
System.out.println(mainName);
}
}
}
![Trần Ngọc Hải [T1907A]](https://www.gravatar.com/avatar/9f7a27af52cbf0d52c32019e1354d60a.jpg?s=80&d=mm&r=g)
Trần Ngọc Hải
2020-03-18 09:34:12
EX1:
Main:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Exam1;
import java.util.Scanner;
/**
*
* @author HAI
*/
public class ConversUtil {
public static void main(String[] args) {
ConversionUtil exam = new ConversionUtil();
Scanner scan = new Scanner(System.in);
System.out.print(" Fahrenheit to Celsius : \n");
double a,b ;
System.out.println("Enter Fahrenheit : ");
a= Double.parseDouble(scan.nextLine());
System.out.println(">>>>"+exam.fahrenheitToCelsius(a));
System.out.println("Celsius to Fahrenheit : ");
System.out.println("Enter Celsius : ");
b= Double.parseDouble(scan.nextLine());
System.out.println(">>>>"+exam.celciusToFahrenheit(b));
}
}
ConversionUtil
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Exam1;
/**
*
* @author HAI
*/
public class ConversionUtil {
public ConversionUtil() {
}
public double fahrenheitToCelsius (double fDegree){
double cDegree;
cDegree = ( (fDegree - 32)*(5/9));
return cDegree ;
}
public double celciusToFahrenheit (double cDegree){
double fDegree;
fDegree = (cDegree * (9/5) + 32);
return fDegree;
}
}
EX2:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Exam2;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author HAI
*/
public class Ex2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String str;
System.out.println("Nhập vào chuỗi văn bản");
str = scan.nextLine();
StringTokenizer st = new StringTokenizer(str);
System.out.println("kết quả : ");
while (st.hasMoreTokens()) {
System.out.print(" \n "+st.nextToken()+" \n \n");
}
}
}
![Hoang Ngo [T1907A]](https://www.gravatar.com/avatar/9f7d962f002d4b5c555b1ee25b3622ff.jpg?s=80&d=mm&r=g)
Hoang Ngo
2020-03-18 09:30:25
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Examination;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author PC
*/
public class Splitsgtring {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Nhap chuoi: ");
String a = scanner.nextLine();
StringTokenizer s = new StringTokenizer(a);
while(s.hasMoreTokens()){
System.out.println(s.nextToken());
}
}
}
bài 2/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Examination;
import java.util.Scanner;
/**
*
* @author PC
*/
public class ConversionUtil {
double fahrenheitToCelsius(double fDegree){
return 5*(fDegree-32)/9;
}
double celciusToFahrenheit(double cDegree){
return (9*cDegree/5)+32;
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Examination;
import java.util.Scanner;
/**
*
* @author PC
*/
public class Driver {
public static void main(String[] args) {
double fahrenheit, cecius;
ConversionUtil cvu = new ConversionUtil();
Scanner scanner = new Scanner(System.in);
System.out.println("Nhap Fahrenheit: ");
fahrenheit = scanner.nextDouble();
System.out.println(fahrenheit + " độ F = " + cvu.fahrenheitToCelsius(fahrenheit) + " độ C");
System.out.println("Nhap Celcius: ");
cecius = scanner.nextDouble();
System.out.println(cecius + " độ C = " + cvu.celciusToFahrenheit(cecius) + " độ F");
}
}
bai1
![Hoang Ngo [T1907A]](https://www.gravatar.com/avatar/9f7d962f002d4b5c555b1ee25b3622ff.jpg?s=80&d=mm&r=g)
Hoang Ngo
2020-03-18 09:30:25
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Examination;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author PC
*/
public class Splitsgtring {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Nhap chuoi: ");
String a = scanner.nextLine();
StringTokenizer s = new StringTokenizer(a);
while(s.hasMoreTokens()){
System.out.println(s.nextToken());
}
}
}
bài 2/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Examination;
import java.util.Scanner;
/**
*
* @author PC
*/
public class ConversionUtil {
double fahrenheitToCelsius(double fDegree){
return 5*(fDegree-32)/9;
}
double celciusToFahrenheit(double cDegree){
return (9*cDegree/5)+32;
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Examination;
import java.util.Scanner;
/**
*
* @author PC
*/
public class Driver {
public static void main(String[] args) {
double fahrenheit, cecius;
ConversionUtil cvu = new ConversionUtil();
Scanner scanner = new Scanner(System.in);
System.out.println("Nhap Fahrenheit: ");
fahrenheit = scanner.nextDouble();
System.out.println(fahrenheit + " độ F = " + cvu.fahrenheitToCelsius(fahrenheit) + " độ C");
System.out.println("Nhap Celcius: ");
cecius = scanner.nextDouble();
System.out.println(cecius + " độ C = " + cvu.celciusToFahrenheit(cecius) + " độ F");
}
}
bai1
![lê văn phương [T1907A]](https://www.gravatar.com/avatar/a07ddfb51e1e7189c76b4e42dbdbcddc.jpg?s=80&d=mm&r=g)
lê văn phương
2020-03-18 09:30:10
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ex2;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author HOME
*/
public class Ex2 {
public static void main(String[] args) {
StringTokenizer st = new StringTokenizer("Toi ten la VietTut");
System.out.println("Tổng số token: " + st.countTokens());
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
}
}
ex2
public static void main(String[] args)
{
Double temp;
Double cel;
Scanner scan = new Scanner(System.in);
System.out.println("Enter temperature in Farenheit");
temp = Double.parseDouble(scan.nextLine());
System.out.println(ConversionUtil.fahrenheitToCelcius(temp));
System.out.println("Enter temperature in celcius");
cel = Double.parseDouble(scan.nextLine());
System.out.println(ConversionUtil.celciusToFahrenheit(cel));
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment;
import java.util.Scanner;
/**
*
* @author HOME
*/
public class ConversionUtil {
public static double fahrenheitToCelcius(Double fDegree)
{
return (double) ((5.0/9.0) * (fDegree - 32));
}
public static double celciusToFahrenheit(Double cDegree)
{
return (double) ((9/5) * (cDegree) + 32);
}
double fahrenheitToCelsius(double temperature) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment;
/**
*
* @author HOME
*/
public class override {
public interface ConversionUtilImpl {
public double fahrenheitToCelsius(double fDegree);
public double celciusToFahrenheit(double cDegree);
}
}
![Lê Minh Bắc [T1907A]](https://www.gravatar.com/avatar/22abcac77d8ca5e01144e240abb48d22.jpg?s=80&d=mm&r=g)
Lê Minh Bắc
2020-03-18 09:27:02
Bài 1:
package Exercise1;
public class ConversionUtil {
public double fahrenheitToCelsius(double fDegree) {
return (double) ((5.0/9.0) * (fDegree - 32));
}
public double celciusToFahrenheit(double cDegree) {
return (double) (((cDegree) * 1.8) + 32);
}
}
package Exercise1;
import java.util.Scanner;
public class Driver {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ConversionUtil con = new ConversionUtil();
System.out.print("Nhập vào độ Celcius cần đổi: ");
double celsius = Double.parseDouble(scanner.nextLine());
System.out.println(celsius + " Celcius = " + con.celciusToFahrenheit(celsius) + " Fahrenheit");
System.out.print("Nhập vào độ Fahrenheit cần đổi: ");
double fahrenheit = Double.parseDouble(scanner.nextLine());
System.out.println(fahrenheit + " Fahrenheit = " + con.fahrenheitToCelsius(fahrenheit) + " Celcius");
}
}
Bài 2:
package Exercise2;
import java.util.Scanner;
import java.util.StringTokenizer;
public class exercise2 {
public static void main(String[] args) {
String str;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
str = scanner.nextLine();
StringTokenizer string = new StringTokenizer(str);
System.out.println("Result: ");
while(string.hasMoreElements()) {
System.out.println(string.nextElement());
}
}
}
![Trần Mạnh Dũng [T1907A]](https://www.gravatar.com/avatar/ee4661d1f9133c241d6c8287c7ea8ceb.jpg?s=80&d=mm&r=g)
Trần Mạnh Dũng
2020-03-18 09:23:23
package ex2;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Ex2 {
public static void main(String[] args) {
String str ="";
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
str = scanner.nextLine();
StringTokenizer chuoi = new StringTokenizer(str);
System.out.println("Result: ");
while(chuoi.hasMoreElements())
System.out.println(chuoi.nextElement());
}
}
bai1
package ex1;
public class ConversionUtil {
double fahrenheitToCelsius(double fDegree){
return 5*(fDegree-32)/9;
}
double celciusToFahrenheit(double cDegree){
return (9*cDegree/5)+32;
}
}
package ex1;
import java.util.Scanner;
public class driver {
public static void main(String[] args) {
System.out.print("Enter fahrenheit convert to celsius: ");
ConversionUtil covUtil = new ConversionUtil();
Scanner sc = new Scanner(System.in);
double fah, cel;
fah = sc.nextDouble();
System.out.print("Celsius: ");
System.out.println(covUtil.fahrenheitToCelsius(fah));
System.out.print("Enter celsius conver to fahrenheit: ");
cel = sc.nextDouble();
System.out.print("Fahrenheilt: ");
System.out.println(covUtil.celciusToFahrenheit(cel));
}
}
![Minh Nghia [T1907A]](https://www.gravatar.com/avatar/ecca255d725eed36a872105205af1b8e.jpg?s=80&d=mm&r=g)
Minh Nghia
2020-03-18 09:23:23
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Java;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class ConversionUtil {
public double fahrenheitToCelsius(double fDegree){
return 5 * (fDegree - 32) / 9;
}
public double celciusToFahrenheit(double cDegree){
return 9 * (cDegree / 5) + 32;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Java;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class Driver {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
ConversionUtil cv = new ConversionUtil();
System.out.println("Enter temperature in Fahrenheit");
Double t = Double.parseDouble(scan.nextLine());
System.out.println(cv.fahrenheitToCelsius(t));
Double c = Double.parseDouble(scan.nextLine());
System.out.println(cv.celciusToFahrenheit(c));
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Java;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author Administrator
*/
public class Exercise2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter a string :");
String s = scan.nextLine();
StringTokenizer st = new StringTokenizer(s);
while(st.hasMoreTokens()){
System.out.println(st.nextToken());
}
}
}
![Nguyễn Văn Quang [T1907A]](https://www.gravatar.com/avatar/e40ab58e34debd5a0dbf4bcfa90bded0.jpg?s=80&d=mm&r=g)
Nguyễn Văn Quang
2020-03-18 09:23:08
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment;
import java.util.Scanner;
/**
*
* @author Quang
*/
public class Driver {
public static void main(String[] args)
{
Double temp;
Double cel;
Scanner scan = new Scanner(System.in);
System.out.println("Enter temperature in Farenheit");
temp = Double.parseDouble(scan.nextLine());
System.out.println(ConversionUtil.fahrenheitToCelcius(temp));
System.out.println("Enter temperature in celcius");
cel = Double.parseDouble(scan.nextLine());
System.out.println(ConversionUtil.celciusToFahrenheit(cel));
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author Quang
*/
public class Splitstring {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Moi ban nhap vao mot chuoi");
String m = scan.nextLine();
StringTokenizer st = new StringTokenizer(m);
while(st.hasMoreElements())
{
System.out.println(st.nextToken());
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment;
/**
*
* @author Quang
*/
public class ConversionUtil {
public static double fahrenheitToCelcius(Double fDegree)
{
return (double) ((5.0/9.0) * (fDegree - 32));
}
public static double celciusToFahrenheit(Double cDegree)
{
return (double) ((9.0/5.0) * (cDegree) + 32);
}
}